#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int i, j;
    char a[n][n];
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) cin >> a[i][j];
    }
    vector<pair<int, int> > ans;
    if (a[1][0] != a[0][1]) {
      if (a[1][0] == a[n - 1][n - 2]) {
        ans.push_back(make_pair(1, 0));
        a[1][0] = a[1][0] == '0' ? '1' : '0';
      } else if (a[0][1] == a[n - 1][n - 2]) {
        ans.push_back(make_pair(0, 1));
        a[0][1] = a[0][1] == '0' ? '1' : '0';
      }
    }
    if (a[n - 1][n - 2] != a[n - 2][n - 1]) {
      if (a[1][0] == a[n - 1][n - 2]) {
        ans.push_back(make_pair(n - 1, n - 2));
      } else if (a[1][0] == a[n - 2][n - 1]) {
        ans.push_back(make_pair(n - 2, n - 1));
      }
    }
    if (a[n - 1][n - 2] == a[1][0]) {
      ans.push_back(make_pair(n - 1, n - 2));
      ans.push_back(make_pair(n - 2, n - 1));
    }
    cout << ans.size() << endl;
    for (i = 0; i < ans.size(); i++) {
      cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
    }
  }
}
