import java.util.Scanner;

public class B {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        for(int j=0;j<t;j++){
            int n=sc.nextInt();
            String[] ar=new String[n];
            sc.nextLine();
            for(int i=0;i<n;i++){
                ar[i]=sc.nextLine();
            }
            int a=Integer.parseInt(String.valueOf(ar[0].charAt(1)));
            int b=Integer.parseInt(String.valueOf(ar[1].charAt(0)));
            int c=Integer.parseInt(String.valueOf(ar[n-2].charAt(n-1)));
            int d=Integer.parseInt(String.valueOf(ar[n-1].charAt(n-2)));
            if(a==b&&c==d){
                if(a==c){
                    System.out.println("0");
                }else{
                    System.out.println("2");
                    System.out.println("1 2");
                    System.out.println("2 1");
                }
            }else if(a==b){
                if(c!=a){
                    System.out.println("1");
                    System.out.print(n +" ");
                    System.out.print(n-1);
                    System.out.println();
                }else{
                    System.out.println("1");
                    System.out.print(n-1);
                    System.out.print(" "+n);
                    System.out.println();
                }
            }else if(c==d){
                if(a!=c){
                    System.out.println("1");
                    System.out.println("2 1");
                }else{
                    System.out.println("1");
                    System.out.println("1 2");
                }
            }else{
                System.out.println("2");
                if(a==c||b==d){
                    System.out.println("2 1");
                    System.out.print(n-1);
                    System.out.print(" "+n);
                    System.out.println();
                }else{
                    System.out.println("1 2");
                    System.out.print(n-1);
                    System.out.print( " "+n);
                    System.out.println();
                }
            }
        }
    }
}
