King

아직 제출이 없습니다시간 제한2초메모리 제한256 MB

문제

As we all know, the number of Pang's papers follows exponential growth. Therefore, we are curious about King sequence.

You are given a prime pp. A sequence (a_1,a_2,,a_n)(a\_1,a\_2,\ldots,a\_n) is a King sequence if and only if there is an integer 1q<p1\leq q < p such that for all integers i\[2,n]i\in \[2,n], qa_i1a_i(modp)q a\_{i-1} \equiv a\_i \pmod p.

Given a sequence B=(b_1,,b_m)B=(b\_1,\ldots,b\_m), what is the length of the longest King subsequence of BB

A subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.

PangPang is super busy recently, so the only thing he wants to know is whether the answer is greater than or equal to n2\frac{n}{2}

If the length of the longest King sequence is less than n2\frac{n}{2}, output 1-1. Otherwise, output the length of the longest King subsequence.

입력

The first line contains an integer TT denoting the number of test cases (1T10001\le T\le 1000).

The first line in a test case contains two integers nn and pp (2n2000002\le n \le 200000, 2p10000000072\le p \le 1000000007, pp is a prime). The sum of nn over all test cases does not exceed 200000200000.

The second line in a test case contains a sequence b_1,,b_nb\_1,\ldots, b\_n (1b_i<p1\le b\_i< p).

출력

For each test case, output one line containing the answer which is 1-1 or the length of the longest King subsequence.