import java.util.Scanner;

public class Solution {

	static void fn(int[][] s) {
		int n = s.length;
		
		int l1 = s[1][0], l2 = s[0][1];
		int r1 = s[n-2][n-1], r2 = s[n-1][n-2];
		
		if(r1 == r2 && l1 == l2) {
			if(r1 == l2) {
				System.out.println(2);
				System.out.println((n-1) + " " + n);
				System.out.println(n + " " + (n-1));
			}else {
				System.out.println(0);
			}
			return;
		}
		
		
		
		
		if(l1 == l2) {
			if(r1 == l1) {
				System.out.println(1);
				System.out.println((n-1) + " " + n);
			}else {
				System.out.println(1);
				System.out.println(n + " " + (n-1));
			}
		}else {
			if(r1 == l1) {
				System.out.println(2);
				System.out.println(2 + "" + 1);
				System.out.println(n + " " + (n-1));
			}else {
				System.out.println(2);
				System.out.println(2 + "" + 1);
				System.out.println((n-1) + " " + n);
			}
		}
		
		
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		for (int i = 0; i < t; i++) {
			int n = sc.nextInt();
			int[][] grid = new int[n][n];
			for (int x = 0; x < n; x++) {
				String str = sc.next();
				int pl = 0;
				for (char c : str.toCharArray()) {
					grid[x][pl++] = c - 48;
				}
			}
			fn(grid);
		}
		sc.close();
	}
}