#include <bits/stdc++.h>
using namespace std;
const int N = 210, M = N << 1, inf = 0x3f3f3f3f, mod = 1000007;
int T, n;
char g[N][N];
bool vis[N][N];
int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
bool bfs(int a, int b) {
  memset(vis, 0, sizeof vis);
  queue<pair<int, int> > q;
  q.push({a, b});
  vis[a][b] = true;
  while (!q.empty()) {
    auto t = q.front();
    q.pop();
    for (int i = 0; i < 4; i++) {
      int x = t.first + dx[i], y = t.second + dy[i];
      if (x < 1 || x > n || y < 1 || y > n) continue;
      if (g[x][y] != g[a][b] || vis[x][y]) continue;
      q.push({x, y});
      vis[x][y] = true;
    }
  }
  return vis[1][2] || vis[2][1];
}
void solve() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> g[i] + 1;
  int cnt = 0;
  vector<pair<int, int> > res;
  if (bfs(n, n - 1)) {
    cnt++;
    res.push_back({n, n - 1});
  }
  if (bfs(n - 1, n)) {
    cnt++;
    res.push_back({n - 1, n});
  }
  cout << cnt << endl;
  for (auto x : res) cout << x.first << " " << x.second << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> T;
  while (T--) solve();
  return 0;
}
