import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int t= in.nextInt();
        for(int i=0;i<t;i++)
            Solution.solve(in, out);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
        public int[] readArray(int n)
        {
            int[] arr=new int[n];
            for(int i=0;i<n;i++) arr[i]=nextInt();
            return arr;
        }
    }
}
class Solution
{
    public static void solve(Main.InputReader in, PrintWriter out)
    {
        int n=in.nextInt();
        char[][] grid=new char[n][n];
        for(int i=0;i<n;i++)
        {
            String s=in.next();
            for(int j=0;j<n;j++)
                grid[i][j]=s.charAt(j);
        }
        char[] a={grid[0][1],grid[1][0]};
        char[] b={grid[n-2][n-1],grid[n-1][n-2]};
        int count=0;
        int[][] dd=new int[2][2];
        if(a[0]==a[1])
        {
            if(b[0]==a[0])
            {
                dd[count][0]=n-1;
                dd[count][1]=n;
                count++;
            }
            if(b[1]==a[0])
            {
                dd[count][0]=n;
                dd[count][1]=n-1;
                count++;
            }
        }
        else
        {
            if(b[0]==b[1])
            {
                if(b[0]==a[0])
                {
                    dd[count][0]=1;
                    dd[count][1]=2;
                    count++;
                }
                if(b[0]==a[1])
                {
                    dd[count][0]=2;
                    dd[count][1]=1;
                    count++;
                }
            }
            else
            {
                if(a[0]==b[0] && a[1]==b[1]) {
                    dd[count][0] = 1;
                    dd[count][1] = 2;
                    count++;
                    dd[count][0] = n - 1;
                    dd[count][1] = n;
                    count++;
                }
                else
                {
                    dd[0][0]=1;
                    dd[0][1]=2;
                    dd[1][0]=n;
                    dd[1][1]=n-1;
                }
            }
        }
        out.println(count);
        for(int i=0;i<count;i++) {
            out.print(dd[i][0] + " " + dd[i][1]);
            out.println();
        }
    }
}