#include <bits/stdc++.h>
using namespace std;
using namespace std;
struct debugger {
  static void call(string::iterator it, string::iterator ed) {}
  template <typename T, typename... aT>
  static void call(string::iterator it, string::iterator ed, T a, aT... rest) {
    string b;
    for (; *it != ','; ++it)
      if (*it != ' ') b += *it;
    cout << b << "=" << a << " ";
    call(++it, ed, rest...);
  }
};
int t, grid[15][15], g;
int checkCS(int oneOrZero);
int checkCF(int oneOrZero);
int main() {
  char a;
  scanf("%d", &t);
  while (t--) {
    grid[20][20] = {0};
    scanf("%d", &g);
    for (int i = 0; i < g; i++) {
      scanf("\n");
      for (int j = 0; j < g; j++) {
        scanf("%c", &a);
        if (a == '0')
          grid[i][j] = 0;
        else if (a == '1')
          grid[i][j] = 1;
      }
    }
    int cS = checkCS(1), cF = checkCF(0);
    int c = max(abs(cS - cF), cS + cF);
    printf("%d\n", c);
    if (c) {
      if (cS == 2 && c == 2) {
        printf("1 2\n2 1\n");
        continue;
      } else if (cS == 0 && c == 2) {
        printf("%d %d\n%d %d\n", g - 1, g, g, g - 1);
        continue;
      } else if (c == 2) {
        printf("1 2\n");
        if (grid[0][2] == grid[g - 1 - 1][g - 1]) {
          printf("%d %d\n", g - 1, g);
        } else {
          printf("%d %d\n", g, g - 1);
        }
      }
      if (cS == 1) {
        if (grid[1][0] == 1)
          printf("1 2\n");
        else
          printf("2 1\n");
      } else {
        if (grid[g - 1 - 1][g - 1] == 0)
          printf("%d %d\n", g - 1, g);
        else
          printf("%d %d\n", g, g - 1);
      }
    }
  }
  return 0;
}
int checkCS(int oneOrZero) {
  int result = 0;
  if (grid[0][1] == oneOrZero) result++;
  if (grid[1][0] == oneOrZero) result++;
  return result;
}
int checkCF(int oneOrZero) {
  int result = 0;
  if (grid[g - 1 - 1][g - 1] == oneOrZero) result++;
  if (grid[g - 1][g - 1 - 1] == oneOrZero) result++;
  return result;
}
