#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int i, j, k, m, n, l, res = 0, zero = 0, one = 0;
    cin >> n;
    vector<pair<int, int> > v;
    string s[n + 1];
    for (i = 0; i < n; i++) {
      cin >> s[i];
    }
    if (s[0][1] == s[1][0]) {
      if (s[0][1] == '1')
        one++;
      else
        zero++;
      if (one > zero) {
        if (s[n - 1][n - 2] == '1') {
          v.push_back({n, n - 1});
        }
        if (s[n - 2][n - 1] == '1') {
          v.push_back({n - 1, n});
        }
      } else {
        if (s[n - 1][n - 2] == '0') {
          v.push_back({n, n - 1});
        }
        if (s[n - 2][n - 1] == '0') {
          v.push_back({n - 1, n});
        }
      }
    } else if (s[n - 1][n - 2] == s[n - 2][n - 1]) {
      one = zero = 0;
      if (s[n - 1][n - 2] == '1')
        one++;
      else
        zero++;
      if (one > zero) {
        if (s[0][1] == '1') {
          v.push_back({0, 1});
        }
        if (s[1][0] == '1') {
          v.push_back({1, 0});
        }
      } else {
        if (s[0][1] == '0') {
          v.push_back({0, 1});
        }
        if (s[1][0] == '0') {
          v.push_back({1, 0});
        }
      }
    }
    {}
    cout << v.size() << '\n';
    for (i = 0; i < v.size(); i++) {
      cout << v[i].first << " " << v[i].second << '\n';
    }
  }
}
