#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    int n;
    cin >> n;
    vector<vector<char>> v(n + 1, vector<char>(n + 1));
    for (int y = 1; y <= n; ++y) {
      for (int x = 1; x <= n; ++x) {
        char c;
        cin >> c;
        v[x][y] = c;
      }
    }
    int countR = 0;
    vector<pair<int, int>> res;
    if (v[n][n - 1] == v[n - 1][n]) {
      auto X = v[n][n - 1];
      if (v[n - 2][n] == v[n - 1][n - 1] && v[n - 1][n - 1] == v[n][n - 2]) {
        if (v[n][n - 2] == X) {
          countR = 2;
          res.push_back({n, n - 1});
          res.push_back({n - 1, n});
        }
      } else {
        auto counting = [&countR, &res, &X, &v](int x, int y) {
          if (v[x][y] == X) {
            ++countR;
            res.push_back({x, y});
          }
        };
        counting(n - 2, n);
        counting(n, n - 2);
        counting(n - 1, n - 1);
      }
    } else {
      if (v[n - 2][n] == v[n - 1][n - 1] && v[n - 1][n - 1] == v[n][n - 2]) {
        auto X = v[n - 1][n - 1];
        if (v[n][n - 1] == X) {
          ++countR;
          res.push_back({n, n - 1});
        } else {
          ++countR;
          res.push_back({n - 1, n});
        }
      } else {
        vector<pair<int, int>> o;
        vector<pair<int, int>> z;
        auto counting = [&o, &z, &v](int x, int y) {
          if (v[x][y] == '1') {
            o.push_back({x, y});
          } else
            z.push_back({x, y});
        };
        counting(n, n - 2);
        counting(n - 2, n);
        counting(n - 1, n - 1);
        char Y;
        if (o.size() < z.size()) {
          Y = '0';
          swap(o, res);
        } else {
          Y = '1';
          swap(z, res);
        }
        if (v[n][n - 1] == Y)
          res.push_back({n, n - 1});
        else
          res.push_back({n - 1, n});
      }
    }
    cout << res.size() << endl;
    for (auto p : res) cout << p.first << " " << p.second << endl;
  }
  return 0;
}
