#include <bits/stdc++.h>
using namespace std;
bool isrange(int second, int first, int n, int m) {
  if (0 <= second && second < n && 0 <= first && first < m) return true;
  return false;
}
int dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1},
    ddy[8] = {1, 0, -1, 0, 1, 1, -1, -1}, ddx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
string a[222];
int dp[222][222], n;
bool can(int second, int first) {
  if (second == n - 1 && first == n - 1) return true;
  dp[second][first] = 1;
  for (int e = 0; e < 4; e++) {
    int ny = second + dy[e];
    int nx = first + dx[e];
    if (isrange(ny, nx, n, n) && dp[ny][nx] == 0) {
      if (a[ny][nx] == 'F' || a[ny][nx] == a[second][first]) {
        if (can(ny, nx)) return true;
      }
    }
  }
  return false;
}
void init() {
  for (int e = 0; e < n; e++)
    for (int p = 0; p < n; p++) dp[e][p] = 0;
  dp[0][0] = 1;
}
bool isit() {
  init();
  bool suc1 = can(0, 1);
  init();
  bool suc2 = can(1, 0);
  if (!suc1 || !suc2) return false;
  return true;
}
void inverse(int second, int first) {
  if (a[second][first] == '0')
    a[second][first] = '1';
  else
    a[second][first] = '0';
}
int vv[3][2] = {{0, 1}, {1, 0}, {1, 1}};
int main(void) {
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    for (int e = 0; e < n; e++) cin >> a[e];
    bool suc = false;
    if (!isit()) {
      printf("0\n");
      suc = true;
    }
    if (!suc) {
      for (int e = 0; e < 3; e++) {
        inverse(vv[e][0], vv[e][1]);
        init();
        if (!isit()) {
          printf("1\n%d %d\n", vv[e][0] + 1, vv[e][1] + 1);
          suc = true;
          break;
        }
        inverse(vv[e][0], vv[e][1]);
      }
    }
    if (!suc) {
      for (int e = 0; e < 3; e++) {
        for (int p = e + 1; p < 3; p++) {
          inverse(vv[e][0], vv[e][1]);
          inverse(vv[p][0], vv[p][1]);
          init();
          if (!isit()) {
            printf("2\n");
            printf("%d %d\n", vv[e][0] + 1, vv[e][1] + 1);
            printf("%d %d\n", vv[p][0] + 1, vv[p][1] + 1);
            suc = true;
            break;
          }
          inverse(vv[e][0], vv[e][1]);
          inverse(vv[p][0], vv[p][1]);
        }
        if (suc) break;
      }
    }
  }
  return 0;
}
