Little Tomato keeps a permutation P of the numbers 1 through n on a board. Every day he swaps a few numbers of P to get a new permutation P′, then looks for the longest increasing subsequence (LIS) of P′. He believes that he will eventually find a faster way to compute an LIS.
One day an earthquake shook some of the numbers off the board. Every fallen number goes back into an empty slot, and Tomato picks which slot each one lands in. How long can the LIS of the restored permutation be?
An increasing subsequence is a subsequence whose values grow from left to right.
The first line contains the number of test cases T (1≤T≤100).
Each test case starts with a line holding the length n of the permutation (1≤n≤105). The next line holds the incomplete permutation a1,a2,…,an. If ai=0, the number that sat at position i has fallen off.
The input is always valid. The nonzero values are distinct and lie between 1 and n, and the fallen numbers are exactly the values of 1 through n that do not appear. The whole input is smaller than 10MB.
For each test case, print the largest possible length of the LIS of the restored permutation on its own line.