#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int tt;
  cin >> tt;
  while (tt--) {
    int n;
    cin >> n;
    vector<string> a(n);
    for (string &s : a) {
      cin >> s;
    }
    vector<pair<int, int>> pos = {
        {1, 2}, {2, 1}, {n - 1, n - 2}, {n - 2, n - 1}};
    char str[4] = {a[0][1], a[1][0], a[n - 1][n - 2], a[n - 2][n - 1]};
    vector<pair<int, int>> sol;
    for (const string &s : {"0011", "1100"}) {
      int diff = 0;
      for (int i = 0; i < 4; i++) {
        diff += str[i] != s[i];
      }
      if (diff <= 2) {
        for (int i = 0; i < 4; i++) {
          if (str[i] != s[i]) {
            sol.push_back(pos[i]);
          }
        }
        break;
      }
    }
    cout << sol.size() << '\n';
    for (const auto &[x, y] : sol) {
      cout << x << ' ' << y << '\n';
    }
  }
  return 0;
}
