#include <bits/stdc++.h>
using namespace std;
const long long N = 205;
long long x = 0, t = 0, k, ans, n;
string a[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    ans = 0;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
    }
    long long x = a[0][1];
    long long y = a[1][0];
    long long xx = a[n - 1][n - 2];
    long long yy = a[n - 2][n - 1];
    if (xx == x && xx != yy && x != y)
      cout << 2 << endl << n << " " << n - 1 << endl << 1 << " " << 2 << endl;
    if (xx == x && xx != yy && x == y)
      cout << 1 << endl << n << " " << n - 1 << endl;
    if (xx != x && xx != yy && x != y)
      cout << 2 << endl << n << " " << n - 1 << endl << 2 << " " << 1 << endl;
    if (xx != x && xx != yy && x == y)
      cout << 1 << endl << n - 1 << " " << n << endl;
    if (xx == x && xx == yy && x != y)
      cout << 1 << endl << 1 << " " << 2 << endl;
    if (xx == x && xx == yy && x == y)
      cout << 2 << endl << 1 << " " << 2 << endl << 2 << " " << 1 << endl;
    if (xx != x && xx == yy && x != y)
      cout << 1 << endl << 1 << " " << 2 << endl;
    if (xx != x && xx == yy && x == y) cout << 0 << endl;
  }
}
