import java.util.*;
import java.lang.*;
import java.io.*;
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
	   // Scanner sc=new Scanner(System.in);
	    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	   // int t=1;
	    //t=sc.nextInt();
	    int t=Integer.parseInt(br.readLine());
	    while(--t>=0){
	        //int n=sc.nextInt();
	              int n=Integer.parseInt(br.readLine());
	         String s[]=new String[n];
	        for(int i=0;i<n;i++)s[i]=br.readLine();
	        
	        char x1=s[0].charAt(1);char x2=s[1].charAt(0);
	        char y1=s[n-1].charAt(n-2);char y2=s[n-2].charAt(n-1);
	        if(x1==x2){
	            if(y1==y2){
	                if(x1==y1){
	                    System.out.println(2);
	                    System.out.println(n+" "+(n-1));
	                    System.out.println((n-1)+" "+n);
	                }
	                else{
	                    System.out.println(0);
	                }
	            }
	            else{
	                System.out.println(1);
	                if(x1==y1)
	                System.out.println(n+" "+(n-1));
	                else
	                System.out.println((n-1)+" "+(n));
	            }
	            
	        }
	        else{
	            if(y1==y2){
	                System.out.println(1);
	                if(x1==y1){
	                    System.out.println(1+" "+2);
	                }
	                else{
	                    System.out.println(2+" "+1);
	                }
	                
	            }
	            else{
	                System.out.println(2);
	                if(x1==0)
	                System.out.println(1+" "+2);
	                else
	                System.out.println(2+" "+1);
	                if(y1==1)
	                System.out.println((n)+" "+(n-1));
	                else
	                System.out.println((n-1)+" "+(n));
	            }
	            
	        }
	        
	        
	        
	        
	       
	       
	       
	       
	        
	     
	        
	    }
	    
	}
}
