#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
using namespace std;
const long long mo = (long long)1e9 + 7;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
char mp[210][210];
void work() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> mp[i] + 1;
  }
  int ans = 0;
  vector<int> v;
  if (mp[1][2] == '0') {
    ans++;
    v.push_back(1);
    v.push_back(2);
  }
  if (mp[2][1] == '0') {
    ans++;
    v.push_back(1);
    v.push_back(2);
  }
  if (mp[n - 1][n] == '1') {
    ans++;
    v.push_back(n - 1);
    v.push_back(n);
  }
  if (mp[n][n - 1] == '1') {
    ans++;
    v.push_back(n);
    v.push_back(n - 1);
  }
  if (ans <= 2) {
    cout << ans << "\n";
    for (int i = 0; i < v.size(); i += 2) {
      cout << v[i] << " " << v[i + 1] << "\n";
    }
    return;
  }
  ans = 0;
  v.clear();
  if (mp[1][2] == '1') {
    ans++;
    v.push_back(1);
    v.push_back(2);
  }
  if (mp[2][1] == '1') {
    ans++;
    v.push_back(1);
    v.push_back(2);
  }
  if (mp[n - 1][n] == '0') {
    ans++;
    v.push_back(n - 1);
    v.push_back(n);
  }
  if (mp[n][n - 1] == '0') {
    ans++;
    v.push_back(n);
    v.push_back(n - 1);
  }
  if (ans <= 2) {
    cout << ans << "\n";
    for (int i = 0; i < v.size(); i += 2) {
      cout << v[i] << " " << v[i + 1] << "\n";
    }
    return;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) work();
  return 0;
}
