Problem: Tema bought an old device with a small screen and a worn-out inscription "The Great Equalizer" on the side.
The seller said that the device needs to be given an array of integers as input, after which "The Great Equalizer" will work as follows:
- Sort the current array in non-decreasing order and remove duplicate elements leaving only one occurrence of each element.
- If the current length of the array is equal to , the device stops working and outputs the single number in the array — output value of the device.
- Add an arithmetic progression {} to the current array, where is the length of the current array. In other words, is added to the -th element of the array, when indexed from zero.
- Go to the first step.
To test the operation of the device, Tema came up with a certain array of integers , and then wanted to perform operations on the array of the following type:
- Assign the value () to the element ().
- Give the array as input to the device and find out the result of the device's operation, while the array remains unchanged during the operation of the device.
Help Tema find out the output values of the device after each operation.
Input Format: The first line of the input contains a single integer () — the number of test cases.
Then follows the description of each test case.
The first line of each test case contains a single integer () — the size of the array that Tema initially came up with.
The second line of each test case contains integers () — the elements of the array .
The third line of a set contains a single integer () — the number of operations.
Each of the next lines of a test case contains two integers () and () - the descriptions of the operations.
It is guaranteed that the sum of the values of and the sum of the values of for all test cases do not exceed .
Output Format: For each test case, output integers — the output values of the device after each operation.
Note: Let's consider the first example of the input.
Initially, the array of numbers given as input to the device will be . It will change as follows:
Then, the array of numbers given as input to the device will be . It will change as follows:
The last array of numbers given as input to the device will be . It will change as follows: