import java.util.*;
public class practice {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-->0) {
			StringBuffer s = new StringBuffer();
			int n = sc.nextInt();
			char a[][] = new char[n][n];
			for(int i=0;i<n;i++) {
				String str = sc.next();
				for(int j=0;j<n;j++)
					a[i][j] = str.charAt(j);
			}
			int a1 = a[0][1];
			int a2 = a[1][0];
			int b1 = a[n-2][n-1];
			int b2 = a[n-1][n-2];
			//System.out.println(a1 + " " + a2 + " " + b1 + " " + b2);
			if(a1 == a2 && a2 != b1 && b1 == b2)
				s.append(0);
			else if(a1 == '0') {
				if(b1 == '0' && b2 == '0') 
					s.append(2 + " \n" + (n-1) + " " + (n) + "\n" + (n) + " " + (n-1));
				else if(b1 == '0' && b2 == '1')
					s.append(1 + "\n" + (n-1) + " " + (n));
				else if(b1 == '1' && b2 == '0')
					s.append(1 + "\n" + (n) + " " + (n-1));
			}
			else if(a1 == '1') {
				if(b1 == '1' && b2 == '1') 
					s.append(2 + " \n" + (n-1) + " " + (n) + "\n" + (n) + " " + (n-1));
				else if(b1 == '1' && b2 == '0')
					s.append(1 + "\n" + (n-1) + " " + (n));
				else if(b1 == '0' && b2 == '1')
					s.append(1 + "\n" + (n) + " " + (n-1));
			}
			System.out.println(s);
		}
	}
}
