#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 7;
const int mod = 1e9 + 7;
char ss[maxn][maxn];
int a, b, T, n;
int cnt, ans[4][2], p[4][2];
void check1() {
  for (int i = 1; i <= 2; i++) {
    if (ss[p[i][0]][p[i][1]] == '1') {
      cnt++;
      ans[cnt][0] = p[i][0];
      ans[cnt][1] = p[i][1];
    }
  }
  for (int i = 3; i <= 4; i++) {
    if (ss[p[i][0]][p[i][1]] == '0') {
      cnt++;
      ans[cnt][0] = p[i][0];
      ans[cnt][1] = p[i][1];
    }
  }
}
void check2() {
  for (int i = 1; i <= 2; i++) {
    if (ss[p[i][0]][p[i][1]] == '0') {
      cnt++;
      ans[cnt][0] = p[i][0];
      ans[cnt][1] = p[i][1];
    }
  }
  for (int i = 3; i <= 4; i++) {
    if (ss[p[i][0]][p[i][1]] == '1') {
      cnt++;
      ans[cnt][0] = p[i][0];
      ans[cnt][1] = p[i][1];
    }
  }
}
int main() {
  cin >> T;
  while (T--) {
    scanf("%d", &n);
    p[1][0] = 1;
    p[1][1] = 2;
    p[2][0] = 2;
    p[2][1] = 1;
    p[3][0] = n - 1;
    p[3][1] = n;
    p[4][0] = n;
    p[4][1] = n;
    for (int i = 1; i <= n; i++) scanf("%s", ss[i] + 1);
    cnt = 0;
    check1();
    if (cnt <= 2) {
      printf("%d\n", cnt);
      for (int i = 1; i <= cnt; i++) printf("%d %d\n", ans[i][0], ans[i][1]);
      continue;
    }
    cnt = 0;
    check2();
    if (cnt <= 2) {
      printf("%d\n", cnt);
      for (int i = 1; i <= cnt; i++) printf("%d %d\n", ans[i][0], ans[i][1]);
      continue;
    }
  }
  return 0;
}
