Mexing it Up
The trimex of an array is defined as the three smallest, non-negative integers that don't exist in an array.
For example, for the array the trimex is
.
Given an array containing
numbers, you perform
"update" operations in the form
. This means that you must set the
-th element of the (0-indexed) to be
.
After each operation, output the trimex of the array. It's time to mex it up!
Input
The first line consists of an integer
, the number elements in the array.
The second line contains the elements of the array
.
The next line contains an integer
, the number of operations to perform.
The next lines contain data for the operations, in the form
,
.
Output
Output the trimex of the array after each operation.
Example
Input
4
1 2 5 7
3
1 3
3 4
2 0
Output
0 2 4
0 2 6
2 5 6
- The array starts as
.
- After the first operation,
. The trimex is
.
- After the first operation,
. The trimex is
.
- After the first operation,
. The trimex is
.
Comments