Under construction

Still being built. Things may change

Two Kilers

Time limit10sMemory limit512 MB

Summary
Given an array with point updates, print after each update the length of its longest strictly increasing subsequence, capped at k.
Level

Medium7 of 10

Topics
Segment tree, Dynamic programming, Binary search
Solved
No attempts yet

Statement

Jurek Kiler, the main character of the Polish movie Two Kilers, receives regular deliveries of gold boxes. The value of the ii-th delivery is cic_i, the total value of the gold boxes inside it.

Recently Jurek has become concerned that the values of the deliveries are falling. To check this, he defined a measure for a sequence of deliveries called the disorder of the sequence. For an integer sequence c1,c2,…,cnc_1, c_2, \ldots, c_n, the disorder is the length of its longest strictly increasing subsequence. Formally, it is the largest integer ss such that there are indices i1<i2<…<isi_1 < i_2 < \ldots < i_s with ci1<ci2<…<cisc_{i_1} < c_{i_2} < \ldots < c_{i_s}.

If the disorder is at least kk, Jurek considers his concern unfounded and does not need the exact value. Some gold boxes are stolen, and some arrive late in large batches, so the delivery values can change. After each change, compute the disorder, or output kk if the disorder is at least kk.

Input

The first line contains one integer Z≤10Z \le 10, the number of test cases.

Each test case starts with a line containing two integers nn and kk, the number of deliveries and the parameter kk. The next line contains nn integers c1,c2,…,cnc_1, c_2, \ldots, c_n, the initial delivery values. The next line contains one integer qq, the number of value changes. Each of the following qq lines contains two integers pjp_j and vjv_j, meaning that cpj=vjc_{p_j} = v_j.

Output

For each test case, output qq lines, each containing one natural number. If the disorder after the jj-th change is ss, output min⁡(s,k)\min(s, k) on the jj-th line.

Constraints

n,q∈[1,105]n, q \in [1, 10^5]

ci,vj∈[1,109]c_i, v_j \in [1, 10^9]

pj∈[1,n]p_j \in [1, n]

k∈[1,20]k \in [1, 20]

Examples1

  1. Example 1

    Input
    2
    3 3
    1 1 1
    2
    3 3
    2 2
    5 3
    1 2 3 4 5
    4
    1 5
    4 2
    2 4
    5 1
    
    Expected output
    2
    3
    3
    3
    2
    1