#include <bits/stdc++.h>
using namespace std;
char adj[202][202];
int main() {
  int t, num, a, b, res, n;
  vector<pair<int, int>> v;
  char s;
  cin >> t;
  while (t--) {
    int cnt = 0, t = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        cin >> s;
        adj[i][j] = s;
      }
    }
    num = adj[1][2];
    for (int j = n - 1; j <= n; j++) {
      for (int k = n; k >= 0; k--) {
        if (adj[j][k] == num) {
          t = 1;
          v.push_back({j, k});
        }
      }
    }
    if (t == 0) {
      cout << 0 << endl;
    }
    cout << v.size() << endl;
    for (auto r : v) {
      cout << r.first << " " << r.second << endl;
    }
  }
}
