import java.util.*;
import java.io.*;
 
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		for(int q = pint(in); q > 0; q--) {
			int n = pint(in);
			String s = in.readLine();
			int k1 = s.charAt(1) - '0';
			s = in.readLine();
			int k2 = s.charAt(0) - '0';
			for(int i = 2; i < n - 2; i++) {
				in.readLine();
			}
			if(n > 3) {s = in.readLine();}
			int p1 = s.charAt(n - 1) - '0';
			s = in.readLine();
			int p2 = s.charAt(n - 2) - '0';
			if((k1 ^ k2) == 0) {
				if((p1 ^ p2) == 0) {
					if(p1 != k1) {
						System.out.println(0);
					}else {
						System.out.println(2);
						System.out.print(n);
						System.out.print(' ');
						System.out.println(n - 1);
						System.out.print(n - 1);
						System.out.print(' ');
						System.out.println(n);
					}
				}else {
					if(p1 == k1) {
						System.out.println(1);
						System.out.print(n - 1);
						System.out.print(' ');
						System.out.println(n);
					}else {
						System.out.println(1);
						System.out.print(n);
						System.out.print(' ');
						System.out.println(n - 1);
					}
				}
			}else {
				if((p1 ^ p2) == 0) {
					if(k1 == p1) {
						System.out.println(1);
						System.out.print(1);
						System.out.print(' ');
						System.out.println(2);
					}else {
						System.out.println(1);
						System.out.print(2);
						System.out.print(' ');
						System.out.println(1);
					}
				}else {
					System.out.println(2);
					if(k1 == 0) {
						System.out.print(1);
						System.out.print(' ');
						System.out.println(2);
					}
					if(k2 == 0) {
						System.out.print(2);
						System.out.print(' ');
						System.out.println(1);
					}
					if(p1 == 0) {
						System.out.print(n - 1);
						System.out.print(' ');
						System.out.println(n);
					}
					if(p2 == 0) {
						System.out.print(n);
						System.out.print(' ');
						System.out.println(n - 1);
					}
				}
			}
			
		}
	}
    static int pint(BufferedReader in) throws IOException {return Integer.parseInt(in.readLine());}
    static int pint(StringTokenizer st) {return Integer.parseInt(st.nextToken());}
}