#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  std::cin >> t;
  while (t--) {
    int n, i, j, c = 0;
    cin >> n;
    char a[n + 1][n + 1];
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= n; j++) cin >> a[i][j];
    }
    if (a[n - 1][n] == a[n][n - 1] && a[1][2] == a[2][1]) {
      cout << 0 << "\n";
    } else {
      if (a[n - 1][n] != a[n][n - 1] || a[1][2] != a[2][1]) {
        cout << 1 << "\n";
        if (a[n - 1][n] != a[n][n - 1])
          cout << n - 1 << " " << n << "\n";
        else
          cout << 1 << " " << 2 << "\n";
      } else {
        cout << 2 << "\n";
        cout << n << " " << n - 1 << "\n";
        cout << 1 << " " << 2 << "\n";
      }
    }
  }
  return 0;
}
