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

public class TestClass {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(br.readLine());
        while (t-- > 0) {
            int n = Integer.parseInt(br.readLine());
            char[][] arr = new char[n][n];
            for (int i = 0; i < n; i++) {
                String s1 = br.readLine();

                for (int j = 0; j < n; j++) {
                    arr[i][j] = s1.charAt(i);
                }
            }
            char x=arr[0][1];
            char y=arr[1][0];
            char u=arr[n-2][n-1];
            char v=arr[n-1][n-2];

            if(x==y && u==v && x==u){
                System.out.println(2);
                System.out.println("0 1");
                System.out.println("1 0");
            }else if(x==u && y==v && x!=y){
                System.out.println(2);
                System.out.println("0 1");
                System.out.println((n-1) +" " + (n-2));
            }else if(x==y && x==u && x!=v){
                System.out.println(1);
                System.out.println((n-2)+" "+ (n-1));
            }else if(x==y && x==v && x!=u){
                System.out.println(1);
                System.out.println((n-1)+" "+ (n-2));
            }else if(u==y && u==v && u!=x){
                System.out.println(1);
                System.out.println("1 0");
            }else if(x==u && x==v && x!=y){
                System.out.println(1);
                System.out.println("0 1");
            }
        }
    }
}