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