#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, i, c1, c2, c3, c4;
  cin >> n;
  string s[n];
  for (i = 0; i < n; i++) cin >> s[i];
  c1 = s[0][1];
  c2 = s[1][0];
  c3 = s[n - 2][n - 1];
  c4 = s[n - 1][n - 2];
  if (c1 == c2 && c3 == c4) {
    if (c1 == c3) {
      cout << 2 << endl << n - 1 << " " << n << endl;
      cout << n << " " << n - 1 << endl;
    } else
      cout << 0 << endl;
  } else if (c1 == c2) {
    if (c1 == c3) {
      cout << 1 << endl;
      cout << n - 1 << " " << n << endl;
    } else {
      cout << 1 << endl;
      cout << n << " " << n - 1 << endl;
    }
  } else {
    if (c1 == c3 || c1 == c4 && c2 == c3 || c2 == c4) {
      cout << 2 << endl;
      cout << 1 << " " << 2 << endl;
      cout << 2 << " " << 1 << endl;
    } else if (c1 == c3 || c1 == c4) {
      cout << 1 << endl;
      cout << 1 << " " << 2 << endl;
    } else if (c2 == c3 || c2 == c4) {
      cout << 1 << endl;
      cout << 2 << " " << 1 << endl;
    }
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
}
