#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  scanf("%d", &n);
  string s[n + 1];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  char a = s[0][1];
  char b = s[1][0];
  char c = s[n - 1][n - 2];
  char d = s[n - 2][n - 1];
  int cnt = 2;
  if (a == b && b == c && c == d) {
    cout << 2 << "\n";
    cout << 1 << " " << 2 << "\n";
    cout << 2 << " " << 1 << "\n";
  } else if (a != b && c == d) {
    cout << 1 << "\n";
    if (a == c) {
      cout << 1 << " " << 2 << "\n";
    } else {
      cout << 2 << " " << 1 << "\n";
    }
  } else if (a == b && c != d) {
    cout << 1 << "\n";
    if (a == c) {
      cout << n << " " << n - 1 << "\n";
    } else {
      cout << n - 1 << " " << n << "\n";
    }
  } else if (a == b && c == d && a != c) {
    cout << 0 << "\n";
  }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) solve();
  return 0;
}
