Problem: Ehab loves number theory, but for some reason he hates the number x. Given an array a, find the length of its longest subarray such that the sum of its elements isn't divisible by x, or determine that such subarray doesn't exist.

An array a is a subarray of an array b if a can be obtained from b by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.

Input

The first line contains an integer t (1 ≤ t ≤ 5) — the number of test cases you need to solve. The description of the test cases follows.

The first line of each test case contains 2 integers n and x (1 ≤ n ≤ 10^5, 1 ≤ x ≤ 10^4) — the number of elements in the array a and the number that Ehab hates.

The second line contains n space-separated integers a_1, a_2, …, a_{n} (0 ≤ a_i ≤ 10^4) — the elements of the array a.

Output

For each testcase, print the length of the longest subarray whose sum isn't divisible by x. If there's no such subarray, print -1.

Example

Input


3
3 3
1 2 3
3 4
1 2 3
2 2
0 6


Output


2
3
-1

Note

In the first test case, the subarray [2,3] has sum of elements 5, which isn't divisible by 3.

In the second test case, the sum of elements of the whole array is 6, which isn't divisible by 4.

In the third test case, all subarrays have an even sum, so the answer is -1.

Solution (in JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AXXXXX solver = new AXXXXX();
        solver.solve(1, in, out);
        out.close();
    }

    static class AXXXXX {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int t = in.scanInt();
            while (t-- > 0) {
                int n = in.scanInt();
                int x = in.scanInt();
                int arr[] = new int[n + 1];
                for (int i = 1; i <= n; i++) arr[i] = in.scanInt();
                int ans = 0;

                MinSeg minSeg = new MinSeg(x + 10);
                for (int i = 0; i < x + 10; i++) minSeg.setMin(x, Integer.MAX_VALUE);

                minSeg.setMin(0, 0);

                int c_sum = 0;

                for (int i = 1; i <= n; i++) {
                    c_sum += arr[i];
                    c_sum %= x;


                    long cur = minSeg.min(c_sum, c_sum);
                    minSeg.setMin(c_sum, Integer.MAX_VALUE);

                    long last = minSeg.min(0, x - 1);
                    if (last != Integer.MAX_VALUE) {
                        ans = (int) Math.max(ans, i - last);
                    }


                    minSeg.setMin(c_sum, cur);
                    minSeg.setMin(c_sum, Math.min(cur, i));
                }

                if (ans == 0) ans = -1;
                out.println(ans);

            }

        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (TOTAL <= 0) return -1;
            }
            return buf[INDEX++];
        }

        public int scanInt() {
            int I = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    I *= 10;
                    I += n - '0';
                    n = scan();
                }
            }
            return neg * I;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }

    static class MinSeg {
        long[] tree;
        int n;
        boolean properupdate;

        public MinSeg(int n) {
            this.n = n;
            tree = new long[2 * n];
            Arrays.fill(tree, Long.MAX_VALUE / 2);
            this.properupdate = true;
        }

        public MinSeg(int n, boolean f) {
            this.n = n;
            tree = new long[2 * n];
            Arrays.fill(tree, Long.MAX_VALUE / 2);
            this.properupdate = f;
        }

        public void setMin(int i, long value) {
            i += this.tree.length / 2;
            if (properupdate) this.tree[i] = value;
            else this.tree[i] = Math.min(this.tree[i], value);
            for (; i > 1; i >>= 1) this.tree[i >> 1] = Math.min(this.tree[i], this.tree[i ^ 1]);
        }

        public long min(int a, int b) {
            if (a > b) return Long.MAX_VALUE / 2;
            long res = Long.MAX_VALUE / 2;
            for (a += this.tree.length / 2, b += this.tree.length / 2; a <= b; a = (a + 1) >> 1, b = (b - 1) >> 1) {
                res = Math.min(res, this.tree[a]);
                res = Math.min(res, this.tree[b]);
            }
            return res;
        }

    }
}