#include <bits/stdc++.h>
using namespace std;
int visited[210][210];
string mp[210];
int n;
pair<int, int> ara[4] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
bool dfs(int i, int j, char x) {
  if (i >= n || j >= n) return false;
  if (i == n - 1 && j == n - 1) return false;
  visited[i][j] = 1;
  if (i == 0 && j == 0) return true;
  bool w = false;
  for (auto v : ara) {
    if (i + v.first < 0 || j + v.second < 0 || i + v.first >= n ||
        j + v.second >= n)
      continue;
    if (visited[i + v.first][j + v.second] ||
        mp[i + v.first][j + v.second] != x)
      continue;
    w |= dfs(i + v.first, j + v.second, x);
  }
  return w;
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  int i, j, k, a, b, c, x, y, z, m, t;
  cin >> t;
  string s;
  while (t--) {
    cin >> n;
    getline(cin, s);
    for (i = 0; i < n; i++) {
      getline(cin, mp[i]);
    }
    memset(visited, 0, sizeof(visited));
    ;
    vector<pair<int, int> > h;
    mp[0][0] = mp[n - 2][n - 1];
    if (dfs(n - 2, n - 1, mp[n - 2][n - 1])) {
      h.push_back({n - 1, n});
    }
    memset(visited, 0, sizeof(visited));
    ;
    mp[0][0] = mp[n - 1][n - 2];
    if (dfs(n - 1, n - 2, mp[n - 1][n - 2])) {
      h.push_back({n, n - 1});
    }
    cout << h.size() << "\n";
    for (i = 0; i < h.size(); i++) {
      cout << h[i].first << " " << h[i].second << "\n";
    }
  }
}
