/* 
JAVA program for SCHOOL
Summary: Reports the number of distinct integers in each test case
*/

import java.util.*;

class SCHOOL {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int numCases = sc.nextInt();
        assert numCases > 0;
        while (numCases-- > 0) {
            SCHOOLs.solve(sc);
        }
        assert sc.nextInt() == 0;
    }
}

class SCHOOLs {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        solve(sc);
    }

    public static void solve(Scanner sc) {
        int n = sc.nextInt();
        int m = sc.nextInt();

        assert n >= 1 && n <= 10000;
        assert m >= 1 && m <= 10000;

        Set<Integer> s = new TreeSet<Integer>();
        for (int i = 0; i < m; i++) {
            int v = sc.nextInt();
            assert v >= 1 && v <= n;
            s.add(v);
        }

        System.out.println(s.size());
    }
}


