import java.util.*;
import java.io.*;
public class Codeforces {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sr = new Scanner(System.in);
        int T = sr.nextInt();
        while (T-- > 0) {
            int n=sr.nextInt();
            String s[]=new String[(int)(n)];
            for(int i=0;i<n;i++)
                s[i]=sr.next();
            int one=0,zero=0;
            if(s[0].charAt(1)=='1')
                ++one;
            else
                ++zero;
            if(s[1].charAt(0)=='1')
                ++one;
            else
                ++zero;
            if(s[n-2].charAt(n-1)=='1')
                ++one;
            else
                ++zero;
            if(s[n-1].charAt(n-2)=='1')
                ++one;
            else
                ++zero;
            if(one>zero)
            {
                System.out.println(zero);
                if(s[0].charAt(1)=='0')
                    System.out.println("1 2");
                if(s[1].charAt(0)=='0')
                    System.out.println("2 1");
                if(s[n-2].charAt(n-1)=='0')
                    System.out.println(n-1+" "+n);
                if(s[n-1].charAt(n-2)=='0')
                    System.out.println(n+" "+(n-1));
            }
            else
            {
                System.out.println(one);
                if(s[0].charAt(1)=='1')
                    System.out.println("1 2");
                if(s[1].charAt(0)=='1')
                    System.out.println("2 1");
                if(s[n-2].charAt(n-1)=='1')
                    System.out.println(n-1+" "+n);
                if(s[n-1].charAt(n-2)=='1')
                    System.out.println(n+" "+(n-1));
            }


        }
    }
}



