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