#include <bits/stdc++.h>
using namespace std;
const int d4i[4] = {-1, 0, 1, 0}, d4j[4] = {0, 1, 0, -1};
const int d8i[8] = {-1, -1, 0, 1, 1, 1, 0, -1},
          d8j[8] = {0, 1, 1, 1, 0, -1, -1, -1};
void DBG() {
  cout << "]"
       << "\n";
}
string to_string(string strin) { return strin; }
string to_string(vector<int>& vec) {
  string t = "";
  for (int i = (0), _c = (vec.size() - 1); i <= _c; ++i)
    t += to_string(vec[i]) + (i ^ (vec.size() - 1) ? " " : "");
  return t;
}
template <class H, class... T>
void DBG(H h, T... t) {
  cout << to_string(h);
  if (sizeof...(t)) cout << ", ";
  DBG(t...);
}
template <class T>
bool umin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool umax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
int n;
char c[1001][1001];
bool vis[205][205];
bool ok;
void change(int i, int j) {
  if (c[i][j] == '1')
    c[i][j] = '0';
  else
    c[i][j] = '1';
}
bool inmax(int i, int j) { return i > 0 && i <= n && j > 0 && j <= n; }
void dfs(int i, int j, int sta) {
  if (!inmax(i, j)) return;
  if (vis[i][j]) return;
  if (to_string(sta) == "1" && c[i][j] == '0') return;
  if (to_string(sta) == "0" && c[i][j] == '1') return;
  vis[i][j] = 1;
  if (i == n && j == n) ok = 1;
  for (int k = (0), _c = (3); k <= _c; ++k) {
    dfs(i + d4i[k], j + d4j[k], sta);
  }
}
void test_case() {
  cin >> n;
  for (int i = (1), _c = (n); i <= _c; ++i)
    for (int j = (1), _c = (n); j <= _c; ++j) cin >> c[i][j];
  for (int i = (0), _c = ((1ll << (4)) - 1); i <= _c; ++i) {
    if (__builtin_popcount(i) > 2) continue;
    if ((((i) >> (0)) & 1ll)) change(1, 2);
    if ((((i) >> (1)) & 1ll)) change(2, 1);
    if ((((i) >> (2)) & 1ll)) change(n, n - 1);
    if ((((i) >> (3)) & 1ll)) change(n - 1, n);
    ok = 0;
    memset(vis, 0, sizeof vis);
    dfs(1, 1, 0);
    dfs(1, 1, 1);
    if (!ok) {
      cout << __builtin_popcount(i) << "\n";
      if ((((i) >> (0)) & 1ll)) cout << 1 << " " << 2 << "\n";
      if ((((i) >> (1)) & 1ll)) cout << 2 << " " << 1 << "\n";
      if ((((i) >> (2)) & 1ll)) cout << n << " " << n - 1 << "\n";
      if ((((i) >> (3)) & 1ll)) cout << n - 1 << " " << n - 1 << "\n";
      return;
    }
    if ((((i) >> (0)) & 1ll)) change(1, 2);
    if ((((i) >> (1)) & 1ll)) change(2, 1);
    if ((((i) >> (2)) & 1ll)) change(n, n - 1);
    if ((((i) >> (3)) & 1ll)) change(n - 1, n);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  auto time = clock();
  int test = 1;
  cin >> test;
  while (test--) {
    test_case();
  }
  cerr << "[It took " << fixed << setprecision(3)
       << double(clock() - time) / CLOCKS_PER_SEC << "s]"
       << "\n";
  return 0;
}
