#include <bits/stdc++.h>
using namespace std;
int q, n;
char v[250][250];
int main() {
  cin >> q;
  while (q--) {
    cin >> n;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) cin >> v[i][j];
    vector<pair<int, int>> ans;
    if (v[n - 1][n] == v[n][n - 1]) {
      char want = v[n - 1][n];
      if (v[n - 2][n] == want) ans.emplace_back(n - 2, n);
      if (v[n - 1][n - 1] == want) ans.emplace_back(n - 1, n - 1);
      if (v[n][n - 2] == want) ans.emplace_back(n, n - 2);
    } else {
      int frecv1 = (bool)(v[n - 2][n] == '1') + (bool)(v[n - 1][n - 1] == '1') +
                   (bool)(v[n][n - 2] == '1');
      int frecv0 = (bool)(v[n - 2][n] == '0') + (bool)(v[n - 1][n - 1] == '0') +
                   (bool)(v[n][n - 2] == '0');
      if (frecv1 == 3) {
        if (v[n - 1][n] == '1') ans.emplace_back(n - 1, n);
        if (v[n][n - 1] == '1') ans.emplace_back(n, n - 1);
      } else if (frecv0 == 3) {
        if (v[n - 1][n] == '0') ans.emplace_back(n - 1, n);
        if (v[n][n - 1] == '0') ans.emplace_back(n, n - 1);
      } else if (frecv1 < frecv0) {
        if (v[n - 2][n] == '1') ans.emplace_back(n - 2, n);
        if (v[n - 1][n - 1] == '1') ans.emplace_back(n - 1, n - 1);
        if (v[n][n - 2] == '1') ans.emplace_back(n, n - 2);
        if (v[n - 1][n] == '0') ans.emplace_back(n - 1, n);
        if (v[n][n - 1] == '0') ans.emplace_back(n, n - 1);
      } else {
        if (v[n - 2][n] == '0') ans.emplace_back(n - 2, n);
        if (v[n - 1][n - 1] == '0') ans.emplace_back(n - 1, n - 1);
        if (v[n][n - 2] == '0') ans.emplace_back(n, n - 2);
        if (v[n - 1][n] == '1') ans.emplace_back(n - 1, n);
        if (v[n][n - 1] == '1') ans.emplace_back(n, n - 1);
      }
    }
    cout << ans.size() << '\n';
    for (pair<int, int> p : ans) cout << p.first << ' ' << p.second << '\n';
  }
  return 0;
}
