#include <bits/stdc++.h>
using namespace std;
const int N = 210;
char mp[N][N];
bool vis[N][N];
char cango;
int n;
int dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1};
bool bfs() {
  queue<pair<int, int> > q;
  q.push({0, 0});
  vis[0][0] = true;
  while (!q.empty()) {
    auto t = q.front();
    q.pop();
    for (int i = 0; i < 4; i++) {
      int nx = t.first + dx[i];
      int ny = t.second + dy[i];
      if (mp[nx][ny] == 'F') return true;
      if (mp[nx][ny] != cango) continue;
      if (vis[nx][ny]) continue;
      if (nx < 0 || nx >= n || ny < 0 || ny >= n) {
        continue;
      }
      vis[nx][ny] = true;
      q.push({nx, ny});
    }
  }
  return false;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    memset(vis, 0, sizeof vis);
    cin >> n;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        cin >> mp[i][j];
      }
    }
    cango = '0';
    bool gowith0 = false;
    gowith0 = bfs();
    cango = '1';
    bool gowith1 = false;
    gowith1 = bfs();
    if (gowith0 && gowith1) {
      cout << 2 << '\n';
      cout << 1 << 2 << '\n';
      cout << 2 << 1 << '\n';
    } else if (gowith0) {
      if (mp[0][1] == '0' && mp[1][0] == '0') {
        cout << 2 << '\n';
        cout << 1 << ' ' << 2 << '\n';
        cout << 2 << ' ' << 1 << '\n';
      } else if (mp[0][1] == '0') {
        cout << 1 << '\n';
        cout << 1 << ' ' << 2 << '\n';
      } else if (mp[1][0] == '0') {
        cout << 1 << '\n';
        cout << 2 << ' ' << 1 << '\n';
      }
    } else if (gowith1) {
      if (mp[0][1] == '1' && mp[1][0] == '1') {
        cout << 2 << '\n';
        cout << 1 << ' ' << 2 << '\n';
        cout << 2 << ' ' << 1 << '\n';
      } else if (mp[0][1] == '1') {
        cout << 1 << '\n';
        cout << 1 << ' ' << 2 << '\n';
      } else if (mp[1][0] == '1') {
        cout << 1 << '\n';
        cout << 2 << ' ' << 1 << '\n';
      }
    } else {
      cout << 0 << '\n';
    }
  }
}
