import java.io.PrintWriter;
import java.util.*;

public class Main {

    void solve(Scanner in, PrintWriter out) {
       int t = in.nextInt();
       for (int j = 0; j < t; ++j) {
            int n = in.nextInt();
            int a = -1,  b = -1, c = -1, d = -1;
            for (int i = 0; i < n; ++i) {
                String s = in.next();
                if (i == 0) {
                    a = s.charAt(1);
                }
                if (i == 1) {
                    b = s.charAt(0);
                }
                if (i == n - 2) {
                    c = s.charAt(n - 1);
                }
                if (i == n - 1) {
                    d = s.charAt(n - 2);
                }
            }

            if ((a == b && a == c && a == d) || (a != b && c != d)) {
                out.println(2);
                if (a == b && a == c && a == d) {
                    out.println(1 + " " + 2);
                    out.println(2 + " " + 1);
                } else {
                    out.println(1 + " " + 2);
                    out.println(n - 1 + " " + n);
                }
            } else if ((a == b && c != d) || (a != b && c == d)) {
                out.println(1);
                if (a == b && c != d) {
                    if (c == a)
                        out.println((n - 1) + " " + (n));
                    else
                        out.println((n) + " " + (n - 1));
                } else {
                    if (c == a)
                        out.println(1 + " " + 2);
                    else
                        out.println(2 + " " + 1);
                }
            } else {
                out.println(0);
            }
       }
    }

    public static void main(String[] args) {
        try(Scanner in = new Scanner(System.in);
            PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
        }
    }
}
