import java.io.*;
import java.math.*;
import java.util.*;

class U {
    static boolean debug = false;
    static void out(String s) { System.out.println(s); }
    static void out_(String s) { System.out.print(s); }
    static void d(String s) { if (debug) out(s); }
    static void d_(String s) { if (debug) out_(s); }
    static void azzert(boolean b) { if (!b) throw new RuntimeException(); }
}

public class B {
	public static void main(String[] args) {
		Scanner console = new Scanner(System.in);

		int P = console.nextInt();

		for (int p=0; p < P; p++) {
			int K = console.nextInt();
			int[] ns = new int[12];
			for(int i = 0; i < 12; i++) {
				ns[i] = console.nextInt();
			}

			int numIslands = 0;
			LinkedList<Integer> stack = new LinkedList<Integer>();
			stack.push(ns[0]);

			for(int i = 1; i < 12; i++) {
				int n = ns[i];
				U.d("n:" + n);

				
				if (n == stack.peek()) {
					// do nothing
				} else if (n > stack.peek()) {
					// always add 1 with any increase
					numIslands++;
					U.d("numIslands++");
					stack.push(n);
				} else if (n < stack.peek()){
					// climbing down!

					// keep on closing parentheses until we are at least at the same level
					while(n < stack.peek()) {
						stack.pop();
					}
					if(n > stack.peek()) {
						numIslands ++;
						stack.push(n);
					}
				}
			}


			U.out(K + " " + numIslands);
		}
	}
}