import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int t=s.nextInt();
		
		for(int i=0;i<t;i++)
		{
			int n=s.nextInt();
			
			int[][] arr=new int[n][n];
			
			for(int j=0;j<n;j++)
			{
				String str=s.next();
				
				for(int k=0;k<n;k++) 
				{
					arr[j][k]=str.charAt(k)-'0';
				}
			}
			
			int count=0;
			
			
			int a=arr[0][1];
			int b=arr[1][0];
			
			int c=arr[n-1][n-2];
			int d=arr[n-2][n-1];
			
			if(a+b==0)
			{
				if(c+d==0)
				{
					System.out.println(2);
					System.out.println((n)+" "+(n-1));
					System.out.println((n-1)+" "+(n));
				}
				else if(c+d==1)
				{
					System.out.println(1);
					
					if(c==0)
					{
						System.out.println((n)+" "+(n-1));
					}
					else
					{
						System.out.println((n-1)+" "+(n));
					}
				}
				else
				{
					System.out.println(0);
				}
			}
			else if(a+b==1)
			{
				if(c+d==0)
				{
					System.out.println(1);
					
					if(a==0)
					{
						System.out.println(1+" "+2);
					}
					else
					{
						System.out.println(2+" "+1);
					}
				}
				else if(c+d==1)
				{
					System.out.println(2);
					
					if(a==1)
					{
						System.out.println(1+" "+2);
					}
					else
					{
						System.out.println(2+" "+1);
					}
					
					if(c==0)
					{
						System.out.println((n)+" "+(n-1));
					}
					else
					{
						System.out.println((n-1)+" "+(n));
					}
				}
				else
				{
					System.out.println(1);
					
					if(a==1)
					{
						System.out.println(1+" "+2);
					}
				}
			}
			else
			{
				if(c+d==0)
				{
					System.out.println(0);
				}
				else if(c+d==1)
				{
					System.out.println(1);
					
					if(c==1)
					{
						System.out.println((n)+" "+(n-1));
					}
					else
					{
						System.out.println((n-1)+" "+(n));
					}
					
				}
				else
				{
					System.out.println(2);
					System.out.println(1+" "+2);
					System.out.println(2+" "+1);
				}
			}
			
		}
		
	}
	
}