// Arup Guha
// 2/22/2014
// Solution to 2013 Greater NY Regional Problem A: Islands in the Data Stream

import java.util.*;

public class a {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Go through each case.
		for (int loop=1; loop<=numCases; loop++) {

			// Read in data.
			int caseNum = stdin.nextInt();
			int[] vals = new int[15];
			for (int i=0; i<15; i++)
				vals[i] = stdin.nextInt();

			// Go through each possible island.
			int cnt = 0;
			for (int i=1; i<14; i++) {
				for (int j=i; j<14; j++) {

					// Requirements of an island.
					if (vals[i] != vals[j]) continue;
					if (vals[i-1] >= vals[i]) continue;
					if (vals[j+1] >= vals[j]) continue;

					// Now check the rest of the values in the middle.
					boolean flag = true;
					for (int k=i; k<=j; k++)
						if (vals[k] <= vals[i-1])
							flag = false;

					// This passed!
					if (flag) cnt++;
				}
			}

			System.out.println(loop+" "+cnt);
		}
	}
}