#include <bits/stdc++.h>
using namespace std;
int t, n;
char a[200][200];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        cin >> a[i][j];
      }
    }
    int x = a[1][2];
    int y = a[2][1];
    int i = a[n][n - 1];
    int j = a[n - 1][n];
    if (x == y && i == j && x == i) {
      cout << "2" << endl;
      cout << "1 2" << endl;
      cout << "2 1" << endl;
      continue;
    }
    if (x == y && i == j && x != i) {
      cout << "0" << endl;
      continue;
    }
    if (x != y && i != j && x == i) {
      cout << "2" << endl;
      cout << "1 2" << endl;
      cout << n << " " << n - 1 << endl;
      continue;
    }
    if (x != y && i != j && x != i) {
      cout << "2" << endl;
      cout << "1 2" << endl;
      cout << n - 1 << " " << n << endl;
      continue;
    }
    if (x == y && i != j && x == i) {
      cout << "1" << endl;
      cout << n << " " << n - 1 << endl;
      continue;
    }
    if (x == y && i != j && x != i) {
      cout << "1" << endl;
      cout << n - 1 << " " << n << endl;
      continue;
    }
    if (x != y && i == j && x == i) {
      cout << "1" << endl;
      cout << "1 2" << endl;
      continue;
    }
    if (x != y && i == j && x != i) {
      cout << "1" << endl;
      cout << "2 1" << endl;
      continue;
    }
  }
  return 0;
}
