#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    int n;
    cin >> n;
    vector<string> g(n);
    vector<string> s(n);
    for (int i = 0; i < n; ++i) {
      cin >> g[i];
      s[i] = g[i];
    }
    if (g[1][0] == g[0][1]) {
      g[n - 1][n - 2] = (char)(1 - g[1][0] - '0');
      g[n - 2][n - 1] = (char)(1 - g[1][0] - '0');
    } else if (g[1][0] != g[0][1]) {
      if (g[n - 1][n - 2] == g[n - 2][n - 1]) {
        g[1][0] = (char)(1 - g[n - 1][n - 2] - '0');
        g[0][1] = (char)(1 - g[n - 2][n - 1] - '0');
      } else {
        g[n - 1][n - 2] = '0';
        g[n - 2][n - 1] = '0';
        g[1][0] = '1';
        g[0][1] = '1';
      }
    }
    vector<pair<int, int>> ans;
    if (g[0][1] != s[0][1]) {
      ans.push_back({0, 1});
    }
    if (g[1][0] != s[1][0]) {
      ans.push_back({1, 0});
    }
    if (g[n - 1][n - 2] != s[n - 1][n - 2]) {
      ans.push_back({n - 1, n - 2});
    }
    if (g[n - 2][n - 1] != s[n - 2][n - 1]) {
      ans.push_back({n - 2, n - 1});
    }
    cout << ans.size() << "\n";
    for (auto x : ans) {
      cout << x.first + 1 << " " << x.second + 1 << "\n";
    }
  }
  return 0;
}
