public static void main(String[] args) throws Throwable{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        for (int i = 0, N = parseInt(in.readLine().trim()); i < N; i++) {
            int C = parseInt(in.readLine().trim()), sum = 0;
            ArrayList<Integer> monedas = new ArrayList<Integer>();
            for (int j = 0, M = parseInt(in.readLine().trim()); j < M; j++) {
                monedas.add(parseInt(in.readLine()));
                sum += monedas.get(monedas.size() - 1);
            }
            int[] arr = new int[sum + 1];
            Arrays.fill(arr, MAX_VALUE);
            int max = 1;
            arr[0]=1;
            for (int j = 0; j < monedas.size(); j++)
                for (int j2 = max - 1; j2 >= 0; j2--)
                    if(arr[j2]<MAX_VALUE){
                        arr[monedas.get(j) + j2] = Math.min(arr[j2] + 1, arr[monedas.get(j) + j2]);
                        if(max <= C)
                            max = Math.max(max, monedas.get(j) + j2 + 1);
                    }
            for (int j = C; j < arr.length; j++)
                if(arr[j] < MAX_VALUE){
                    System.out.println(j + " " + (arr[j] - 1));;
                    break;
                }
        }
    }