//"We have two lives, and the second begins when we realize we only have one." — Confucius

import java.io.BufferedReader;
import java.util.*;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class C{
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
		int t = fs.nextInt();
		for(int tt=0;tt<t;tt++)
		{
			int n= fs.nextInt();
			char[][] arr = new char[n][n];
			for(int i=0;i<n;i++)
			{
				String str = fs.next();
				int index = 0;
				for(int j=0;j<n;j++)
				{
					arr[i][j]=str.charAt(index++);
					
				}
			}
			
			/*for(int i=0;i<n;i++)
			{
				for(int j=0;j<n;j++)
				{
					System.out.print(arr[i][j]+" ");
				}
				System.out.println();
			}*/
			int ans =0;
			
			if(arr[0][1]!=arr[1][0] && arr[n-1][n-2]!=arr[n-2][n-1])
			{
				System.out.println(2);
				if(arr[0][1]=='1')
				{
					System.out.println(1+" "+1);
					if(arr[n-2][n-1]=='0')
					{
						System.out.println(n +" "+(n-1));
					}
					else
					{
						System.out.println(n-1+" "+n);
					}
				}
				else
				{
					System.out.println(2+" "+1);
					if(arr[n-2][n-1]=='0')
					{
						System.out.println(n-1 +" "+n);
					}
					else
					{
						System.out.println(n+" "+(n-1));
					}
					
				}
				
				
				
				
			}
			else if(arr[0][1]==arr[1][0])
			{
				int res=0;
				boolean flag1 =false;
				boolean flag2=false;
				char c=arr[0][1];
				if(arr[n-1][n-2]==c)
				{
					flag1=true;
					res++;
				}
				if(arr[n-2][n-1]==c)
				{
					flag2=true;
					res++;
				}
				System.out.println(res);
				if(flag1==true)
				{
					System.out.println(n+" "+(n-1));
				}
				if(flag2==true)
				{
					System.out.println(n-1+" "+n);
				}
				
			}
			
			else
			{
				int res=0;
				boolean flag1 =false;
				boolean flag2=false;
				char c=arr[n-1][n-2];
				if(arr[0][1]==c)
				{
					flag1=true;
					res++;
				}
				if(arr[1][0]==c)
				{
					flag2=true;
					res++;
				}
				System.out.println(res);
				if(flag1==true)
				{
					System.out.println(1+" "+2);
				}
				if(flag2==true)
				{
					System.out.println(2+" "+1);
				}
				
			}
			
			
			
		}
		
		}
	




	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}


