You are given an integer array of length .
Coordinate compression of a contiguous subarray is defined as follows. Let be the number of distinct values in that subarray. Replace each value in the subarray with the number of distinct values in the same subarray that are strictly smaller than . Thus, the resulting values lie between and , inclusive. Elements outside the subarray remain unchanged.
Process the following three types of queries in order.
1 : Coordinate-compress the subarray .2 : Let and be the minimum and maximum values in the subarray . Print a value that occurs in this subarray and is closest to . If multiple distinct values are equally close, print the smallest one.Every query operates on the array after all previous queries have been applied.
The input is given in the following format:
For each type 2 query, print the required value on its own line.
After the first type 1 query, the array becomes . After the second, it becomes .
3 : Add the integer to every element of the subarray .Each query occupies one line and has one of the following three formats:
3 query.1 queries.No additional constraints.
In each of the first two queries, two values are equally close to the midpoint, so the smaller one is printed.