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