#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    char a[n + 5][n + 5];
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        cin >> a[i][j];
      }
    }
    int count = 0;
    if (n * n % 2 == 0) {
      cout << "1" << endl;
      if (a[1][2] == a[n - 1][n]) {
        cout << (n - 1) << " " << n << endl;
      } else {
        cout << n << " " << n - 1 << endl;
      }
    } else {
      if (a[1][2] == a[n][n - 1]) {
        cout << "2" << endl;
        cout << "1"
             << " "
             << "2" << endl;
        cout << "2"
             << " "
             << "1" << endl;
      } else {
        cout << "0" << endl;
      }
    }
  }
  return 0;
}
