import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

/**
 * Sol
 */
public class Sol {

  public static void main(String[] args) {
    int t;
    try (InputStreamReader s = new InputStreamReader(System.in);
         PrintWriter p = new PrintWriter(System.out)) {
      t = s.read() - '0';
      s.read();

      for (; t > 0; t--) {
        int n = s.read() - '0';
        s.read();
        byte g[][] = new byte[n][n];
        for (int i = 0; i < n; i++) {
          for (int j = 0; j < n; j++) {
            g[i][j] = (byte)(s.read() - '0');
          }
          s.read();
        }

        if (g[0][1] == g[1][0]) {
          if (g[n-1][n-2] == g[n-2][n-1]) {
            if (g[n-1][n-2] == g[0][1]) {
              p.println(0);
            } else {
              p.println(2);
              p.println(String.format("%d %d", n-1, n));
              p.println(String.format("%d %d", n, n-1));
            }
          } else {
            p.println(1);
            
            if (g[n-2][n-1] == g[0][1]) {
              p.println(String.format("%d %d", n-1, n));
            } else {
              p.println(String.format("%d %d", n, n-1));
            }
          }
        } else {
          if (g[n-1][n-2] == g[n-2][n-1]) {
            p.println(1);

            if (g[0][1] == g[n-2][n-1]) {
              p.println(String.format("%d %d", 2, 1));
            }

            if (g[1][0] == g[n-2][n-1]) {
              p.println(String.format("%d %d", 1, 2));
            }
          } else {
            System.out.println(2);

            if (g[n-1][n-2] == g[0][1]) {
              p.println(String.format("%d %d", n, n-1));
              p.println(String.format("%d %d", 1, 0));
            } else {
              p.println(String.format("%d %d", n-1, n));
              p.println(String.format("%d %d", 1, 0));
            }
          }
        }
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}