#include <bits/stdc++.h>
using namespace std;
char l1[205][205];
long long z, n;
long long direction2[4][2] = {{1, 0}, {0, 1}, {0, -1}, {-1, 0}};
long long vis[205][205];
bool valid(int a, int b) {
  if (a >= 1 && a <= n && b >= 1 && b <= n)
    return true;
  else
    return false;
}
void bfs(pair<long long, long long> s, char ch) {
  vis[s.first][s.second] = 1;
  for (int i = 0; i < 4; i++) {
    long long x = s.first + direction2[i][0];
    long long y = s.second + direction2[i][1];
    if (valid(x, y) && (l1[x][y] == ch || l1[x][y] == 'F') && !vis[x][y]) {
      if (x == n && y == n) {
        z = 1;
        return;
      } else {
        bfs({x, y}, ch);
      }
    }
  }
}
int main() {
  long long t;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        cin >> l1[i][j];
      }
    }
    z = 0;
    long long z2 = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) vis[i][j] = 0;
    bfs({1, 1}, '0');
    if (z) z2 = 1;
    z = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) vis[i][j] = 0;
    bfs({1, 1}, '1');
    if (z && z2) {
      cout << 2 << endl;
      cout << n - 1 << " " << n << endl;
      cout << n << " " << n - 1 << endl;
    } else if (z) {
      long long cnt = 0;
      if (l1[n - 1][n] == '1') cnt++;
      if (l1[n][n - 1] == '1') cnt++;
      if (cnt == 1) {
        cout << cnt << endl;
        cout << n - 1 << " " << n << endl;
      } else if (cnt == 2) {
        cout << cnt << endl;
        cout << n - 1 << " " << n << endl;
        cout << n << " " << n - 1 << endl;
      }
    } else if (z2) {
      long long cnt = 0;
      if (l1[n - 1][n] == '0') cnt++;
      if (l1[n][n - 1] == '0') cnt++;
      if (cnt == 1) {
        cout << cnt << endl;
        cout << n - 1 << " " << n << endl;
      } else if (cnt == 2) {
        cout << cnt << endl;
        cout << n - 1 << " " << n << endl;
        cout << n << " " << n - 1 << endl;
      }
    } else {
      cout << 0 << endl;
    }
  }
}
