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