#include <bits/stdc++.h>
using namespace std;
int n;
vector<string> a;
void solve() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    a.push_back(s);
  }
  vector<pair<int, int> > p;
  int ans = 0;
  if (a[1][0] == a[0][1]) {
    if (a[1][0] == '1') {
      if (a[n - 1][n - 2] == '1') {
        ++ans;
        p.push_back(make_pair(n - 1, n - 2));
      }
      if (a[n - 2][n - 1] == '1') {
        ++ans;
        p.push_back(make_pair(n - 2, n - 1));
      }
    } else {
      if (a[n - 1][n - 2] == '0') {
        ++ans;
        p.push_back(make_pair(n - 1, n - 2));
      }
      if (a[n - 2][n - 1] == '0') {
        ++ans;
        p.push_back(make_pair(n - 2, n - 1));
      }
    }
  } else if (a[n - 1][n - 2] == a[n - 2][n - 1]) {
    if (a[n - 1][n - 2] == '1') {
      if (a[0][1] == '1') {
        ++ans;
        p.push_back(make_pair(0, 1));
      }
      if (a[1][0] == '1') {
        ++ans;
        p.push_back(make_pair(1, 0));
      }
    } else {
      if (a[0][1] == '0') {
        ++ans;
        p.push_back(make_pair(0, 1));
      }
      if (a[1][0] == '0') {
        ++ans;
        p.push_back(make_pair(1, 0));
      }
    }
  } else {
    ++ans;
    if (a[0][1] == '0') {
      p.push_back(make_pair(0, 1));
      if (a[n - 1][n - 2] == '1') {
        ++ans;
        p.push_back(make_pair(n - 1, n - 2));
      }
      if (a[n - 2][n - 1] == '1') {
        ++ans;
        p.push_back(make_pair(n - 2, n - 1));
      }
    } else {
      p.push_back(make_pair(0, 1));
      if (a[n - 1][n - 2] == '0') {
        ++ans;
        p.push_back(make_pair(n - 1, n - 2));
      }
      if (a[n - 2][n - 1] == '0') {
        ++ans;
        p.push_back(make_pair(n - 2, n - 1));
      }
    }
  }
  cout << ans << "\n";
  for (int i = 0; i < (int)p.size(); ++i) {
    cout << p[i].first + 1 << ' ' << p[i].second + 1 << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
