You are given a sequence of positive integers a1,a2,…,an. You want to place the numbers 1 through n, each exactly once, into positions 1 through n, so that the number placed at position i never exceeds ai. In other words, decide whether a permutation p of 1,…,n exists such that pi≤ai for every 1≤i≤n.
Write a program that reports, for the initial sequence and after each single edit to the sequence, whether such a permutation can be formed.
The first line contains the length of the sequence n (1≤n≤200,000). The second line contains a1,a2,…,an separated by spaces. The third line contains the number of edits m (0≤m≤500,000). Each of the next m lines describes one edit as two integers ji and wi (1≤ji,wi≤n), meaning the ji-th element is changed to wi. Edits are applied cumulatively: the i-th edit is made to the sequence that already includes the previous i−1 edits.
Print m+1 lines. On each line print TAK if a permutation satisfying the condition can be formed, or NIE if it cannot.
The first line is the answer for the initial sequence, and the next m lines are the answers immediately after the 1st through mth edits are applied.
In the sample, the initial sequence admits the permutation 2,4,3,1,5. After the first edit the sequence becomes 3,4,3,2,4, for which no permutation exists. After the second edit it becomes 5,4,3,2,4, for which the permutation 5,1,3,2,4 works.