#include <bits/stdc++.h>
using namespace std;
const int mf[] = {1, -1, 0, 0}, mc[] = {0, 0, -1, 1};
int n;
bool mark[205][205];
vector<string> mat;
bool bfs(char type, int f, int c) {
  for (int i = 0; i <= n; i++) fill(mark[i] + 1, mark[i] + 1 + n, false);
  mark[f][c] = true;
  queue<pair<int, int> > q;
  while (!q.empty()) q.pop();
  q.push(pair<int, int>(f, c));
  while (!q.empty()) {
    f = q.front().first;
    c = q.front().second;
    q.pop();
    for (int i = 0; i < 4; i++) {
      int nf = f + mf[i];
      int nc = c + mc[i];
      if (nf < 1 || nf > n || nc < 1 || nc > n || mark[nf][nc]) continue;
      if (nf == nc && nf == n) return true;
      if (mat[nf][nc] != type) continue;
      mark[nf][nc] = true;
      q.push(pair<int, int>(nf, nc));
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    mat.clear();
    mat.push_back("wewe");
    for (int i = 1; i <= n; i++) {
      string x;
      cin >> x;
      x = "x" + x;
      mat.push_back(x);
    }
    bool ok = true;
    int x = -1, y;
    if (bfs('0', 1, 1)) {
      ok = false;
      for (int i = 1; i <= n && !ok; i++)
        for (int j = 1; j <= n && !ok; j++)
          if (mat[i][j] == '0') {
            mat[i][j] = '1';
            if (bfs('0', 1, 1))
              mat[i][j] = '0';
            else
              ok = true, x = i, y = j;
          }
    }
    if (!ok) {
      cout << 2 << '\n' << 1 << ' ' << 2 << '\n' << 2 << ' ' << 1 << '\n';
      continue;
    }
    int z, t = -1;
    ok = true;
    if (bfs('1', 1, 1)) {
      ok = false;
      for (int i = 1; i <= n && !ok; i++)
        for (int j = 1; j <= n && !ok; j++)
          if (mat[i][j] == '1') {
            mat[i][j] = '0';
            if (bfs('1', 1, 1))
              mat[i][j] = '1';
            else
              ok = true, z = i, t = j;
          }
    }
    if (!ok) {
      cout << 2 << '\n' << 1 << ' ' << 2 << '\n' << 2 << ' ' << 1 << '\n';
      continue;
    }
    int gengte = (t != -1) + (x != -1);
    cout << gengte << '\n';
    if (x != -1) cout << x << ' ' << y << '\n';
    if (t != -1) cout << z << ' ' << t << '\n';
    cout << endl;
  }
  return 0;
}
