import java.io.*;
import java.util.*;
 
 
public class Main{

   public static void main(String[] args) throws IOException{
	
	int t = sc.nextInt();
	while (t-->0){
		int n = sc.nextInt();
		sc.readLine(0);
		int[][] a = new int[n][n];
		for (int i = 0; i < n; i++) {
			String s =sc.readLine(n);
			for (int j = 0; j < n; j++) {
				a[i][j] = s.charAt(j) - '0';
			}
		}
		int sum1 = a[0][1] + a[1][0];
		int sum2 = a[n-1][n-2] + a[n-2][n-1];
		if (a[0][1] + a[1][0] == 2 && a[n-1][n-2] + a[n-2][n-1] == 0) {
			out.println(0);
		}
		else if (a[0][1] + a[1][0] == 0 && a[n-1][n-2] + a[n-2][n-1] == 02) {
			out.println(0);
		}
		else if (sum1 == 2 && sum2 == 2) {
			out.println(2);
			out.println("1 2");
			out.println("2 1");
		}
		else if (sum1 == 0 && sum2 == 0) {
			out.println(2);
			out.println("1 2");
			out.println("2 1");
		}
		else {
			out.println(1);
			if (sum1 + sum2 == 1) {
				if (sum1 == 1) {
					if (a[0][1] == 0) out.println("1 2");
					else out.println("2 1");
				}
				else {
					int x = n-1;
					int y = n;
					if (a[n-2][n-1] == 0) out.println(x + " " + y);
					else out.println(y + " " + x);
				}
			}
			else {
				if (sum1 == 1) {
					if (a[0][1] == 01) out.println("1 2");
					else out.println("2 1");
				}
				else {
					int x = n-1;
					int y = n;
					if (a[n-2][n-1] == 01) out.println(x + " " + y);
					else out.println(y + " " + x);
				}
			}
		}
	}
	
	out.close();
   }
   static long ceil(long a, long b) {
		return (a+b-1)/b;
	}
  
   static long powMod(long base, long exp, long mod) {
	   if (base == 0 || base == 1) return base;
	   if (exp == 0) return 1;
	   if (exp == 1) return base % mod;
	   long R = powMod(base, exp/2, mod) % mod;
	   R *= R;
	   R %= mod;
	   if ((exp & 1) == 1) {
		   return base * R % mod;
	   }
	   else return R % mod;
   }
   
   static long pow(long base, long exp) {
	   if (base == 0 || base == 1) return base;
	   if (exp == 0) return 1;
	   if (exp == 1) return base;
	   long R = pow(base, exp/2);
	   if ((exp & 1) == 1) {
		   return R * R * base;
	   }
	   else return R * R;
   }
   

 
   static class Reader 
   { 
       final private int BUFFER_SIZE = 1 << 16; 
       private DataInputStream din; 
       private byte[] buffer; 
       private int bufferPointer, bytesRead; 

       public Reader() 
       { 
           din = new DataInputStream(System.in); 
           buffer = new byte[BUFFER_SIZE]; 
           bufferPointer = bytesRead = 0; 
       } 

       public Reader(String file_name) throws IOException 
       { 
           din = new DataInputStream(new FileInputStream(file_name)); 
           buffer = new byte[BUFFER_SIZE]; 
           bufferPointer = bytesRead = 0; 
       } 

       public String readLine(int len) throws IOException 
       { 
           byte[] buf = new byte[len+1]; // line length 
           int cnt = 0, c;
           while ((c = read()) != -1) 
           { 
               if (c == '\n') 
               {
            	   break;
               }
               buf[cnt++] = (byte) c; 
           } 
           return new String(buf, 0, Integer.max(cnt-1, 0)); 
       } 

       public int nextInt() throws IOException 
       { 
           int ret = 0; 
           byte c = read(); 
           while (c <= ' ') 
               c = read(); 
           boolean neg = (c == '-'); 
           if (neg) 
               c = read(); 
           do
           { 
               ret = ret * 10 + c - '0'; 
           }  while ((c = read()) >= '0' && c <= '9'); 

           if (neg) 
               return -ret; 
           return ret; 
       } 

       public long nextLong() throws IOException 
       { 
           long ret = 0; 
           byte c = read(); 
           while (c <= ' ') 
               c = read(); 
           boolean neg = (c == '-'); 
           if (neg) 
               c = read(); 
           do { 
               ret = ret * 10 + c - '0'; 
           } 
           while ((c = read()) >= '0' && c <= '9'); 
           if (neg) 
               return -ret; 
           return ret; 
       } 

       public double nextDouble() throws IOException 
       { 
           double ret = 0, div = 1; 
           byte c = read(); 
           while (c <= ' ') 
               c = read(); 
           boolean neg = (c == '-'); 
           if (neg) 
               c = read(); 

           do { 
               ret = ret * 10 + c - '0'; 
           } 
           while ((c = read()) >= '0' && c <= '9'); 

           if (c == '.') 
           { 
               while ((c = read()) >= '0' && c <= '9') 
               { 
                   ret += (c - '0') / (div *= 10); 
               } 
           } 

           if (neg) 
               return -ret; 
           return ret; 
       } 

       private void fillBuffer() throws IOException 
       { 
           bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); 
           if (bytesRead == -1) 
               buffer[0] = -1; 
       } 

       private byte read() throws IOException 
       { 
           if (bufferPointer == bytesRead) 
               fillBuffer(); 
           return buffer[bufferPointer++]; 
       } 

       public void close() throws IOException 
       { 
           if (din == null) 
               return; 
           din.close(); 
       } 
   }

	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static Reader sc = new Reader();
}











