import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int tc=sc.nextInt();
        while (tc-->=1){
           int num=sc.nextInt();
           char ch[][]= new char[num][num];
           for (int i=0;i<num;i++){
               String Str=sc.next();
               for (int j=0;j<num;j++){
                   ch[i][j]=Str.charAt(j);
               }
           }
           boolean flag1=false;
           boolean flag2=false;
           if (ch[0][1]==ch[num-2][num-1]){
               flag1=true;
           }
            if (ch[1][0]==ch[num-1][num-2]){
                flag2=true;
            }
             if (flag1==true&&flag2==true){
                System.out.println(2);
                System.out.println((num-1)+" "+num);
                System.out.println((num)+" "+(num-1));
            }
             else if (flag1){
                System.out.println(1);
                System.out.println((num-1)+" "+num);
            }
              else if (flag2){
                System.out.println(1);
                System.out.println((num)+" "+(num-1));
            }

            else{
                System.out.println(0);
            }
        }

    }
    


}