import java.util.*;
public class S
{
    public static void main(String args[])
    {
        Scanner scan=new Scanner(System.in);
        int test=scan.nextInt();
        while(test>0)
        {
            test--;
            int n=scan.nextInt();
            int arr[][]=new int[n][n];
            arr[0][0]=-1;
            arr[n-1][n-1]=-1;
            String s[]=new String[n];
            for(int i=0;i<n;i++)
            s[i]=scan.next();
            
            for(int i=0;i<n;i++)
            {
                String h=s[i];
                for(int j=0;j<n;j++)
                {
                    char c=h.charAt(j);
                    if(c=='0')
                    arr[i][j]=0;
                    else if(c=='1')
                    arr[i][j]=1;
                    else
                    arr[i][j]=10;
                }
            }
            
            //case 1
            if(arr[0][1]==arr[1][0])
            {
                int a=arr[0][1];
                if((arr[n-1][n-2]==arr[n-2][n-1]))
                {
                    if(arr[n-1][n-2]!=a)
                  System.out.println(0);
                  else
                  {
                     System.out.println(2);
                     System.out.println((n-2)+" "+(n-1));
                     System.out.println((n-1)+" "+(n-2));
                  }
                }
                else
                {
                    if(arr[n-1][n-2]==a)
                    {
                        System.out.println(1);
                        System.out.println((n-1)+" "+(n-2));
                    }
                    else
                    {
                        System.out.println(1);
                        System.out.println((n-2)+" "+(n-1));
                    }
                }
            }
            else if(arr[n-1][n-2]==arr[n-2][n-1])
            {
                int a=arr[n-1][n-2];
                if((arr[0][1]==arr[1][0]))
                {
                    if(arr[0][1]!=a)
                  System.out.println(0);
                  else
                  {
                     System.out.println(2);
                     System.out.println(0+" "+1);
                     System.out.println(1+" "+0);
                  }
                }
                else
                {
                    if(arr[0][1]==a)
                    {
                        System.out.println(1);
                        System.out.println(0+" "+1);
                    }
                    else
                    {
                        System.out.println(1);
                        System.out.println(1+" "+0);
                    }
                }
           
        }
        else
        {
            int a=arr[0][1];
            System.out.println(2);
            System.out.println(1+" "+0);
            if(arr[n-1][n-2]==a)
            System.out.println((n-1)+" "+(n-2));
            else
            System.out.println((n-2)+" "+(n-1));
        }
    }
}
}