import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task1421b solver = new Task1421b();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task1421b {
        private PrintWriter out;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            this.out = out;
            int t = in.nextInt();
            for (int i = 0; i < t; i++) {
                int n = in.nextInt();
                String[][] array = new String[n][n];
                in.nextLine();
                for (int j = 0; j < n; j++) {
                    array[j] = in.nextLine().split("");
                }
                if (!check("0", "1", array)) {
                    check("1", "1", array);
                }
            }
        }

        private boolean check(String x, String y, String[][] s) {
            int n = s.length - 1;
            int a = s[0][1].equals(y) ? 1 : 0;
            int b = s[1][0].equals(y) ? 1 : 0;
            int c = s[n][n - 1].equals(x) ? 1 : 0;
            int d = s[n - 1][n].equals(x) ? 1 : 0;
            int res = a + b + c + d;
            if (res <= 2) {
                out.println(res);
                if (a == 1)
                    out.println("1 2");
                if (b == 1)
                    out.println("2 1");
                if (c == 1)
                    out.println((n + 1) + " " + n);
                if (d == 1)
                    out.println(n + " " + (n + 1));
                return true;
            }
            return false;
        }

    }
}

