import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;



public class main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static void main(String[] args) throws IOException {
        int t = Integer.parseInt(br.readLine());
        while(t-->0){
            int n = Integer.parseInt(br.readLine());
            String[][] arr = new String[n][n];
            for(int i = 0;i<n;i++){
                String[] s = br.readLine().split("");
                for(int j = 0;j<n;j++){
                    arr[i][j] = s[j];
                }
            }
            int[][] a = new int[2][2];
            int f1= Integer.parseInt(arr[0][1]);
            int f2 = Integer.parseInt(arr[1][0]);
            int l1 = Integer.parseInt(arr[n-2][n-1]);
            int l2 = Integer.parseInt(arr[n-1][n-2]);
            int change = 0;
            if(f1==f2 && l1==l2){
                if(l1==f1){
                    change=2;
                    a[0][0]=1;
                    a[0][1]=2;
                    a[1][0]=2;
                    a[1][1]=1;
                }else{
                    change = 0;
                }
            }else if(f1==f2){
                int value = l1==f1?l1:l2;
                if(value==l1){
                    a[0][0] = n-1;
                    a[0][1] = n;
                }else{
                    a[0][0] = n;
                    a[0][1] = n-1;
                }
                change=1;
            }else if(l1==l2){
                int value = l1==f1?f1:f2;
                if(value == f1){
                    a[0][0]=n-1;
                    a[0][1]=n;
                }else{
                    a[0][0]=n;
                    a[0][1]=n-1;
                }
                change=1;
            }else{
                int value1 = f1==0?f1:f2;
                if(value1 == f1){
                    a[0][0] = 1;
                    a[0][1] = 2;
                }else{
                    a[0][0] = 2;
                    a[0][1] = 1;
                }
                value1 = l1==1?l1:l2;
                if(value1==l1){
                    a[1][0]=n-1;
                    a[1][1]=n;
                }else{
                    a[1][0] = n;
                    a[1][1]= n-1;
                }
                change = 2;
            }
            if(a[0][0]==a[0][1] && a[1][0]==a[1][1]){
                System.out.println(0);
            }else{
                System.out.println(change);
                System.out.print(a[0][0]+" "+a[0][1]);
                if(a[1][0]!=0){
                    System.out.println();
                    System.out.print(a[1][0]+" "+a[1][1]);
                }
            }
            System.out.println();

        }
    }
}