#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a[2][2] = {{0, 0}, {0, 0}};
  cin >> n;
  int ll[n];
  char x, l[n][4];
  for (int i = 0; i < n; i++) {
    cin >> m;
    ll[i] = m;
    for (int k = 0; k < m; k++) {
      for (int j = 0; j < m; j++) {
        cin >> x;
        if ((k == 0) && (j == 1)) l[i][0] = x;
        if ((k == 1) && (j == 0)) l[i][1] = x;
        if ((k == m - 1) && (j == m - 2)) l[i][2] = x;
        if ((k == m - 2) && (j == m - 1)) l[i][3] = x;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    a[0][0] = 0;
    a[1][0] = 0;
    a[0][1] = 0;
    a[1][1] = 0;
    m = 0;
    if (l[i][0] == l[i][1]) {
      if (l[i][0] == l[i][2]) {
        m++;
        a[0][0] = ll[i];
        a[0][1] = ll[i] - 1;
      }
      if (l[i][0] == l[i][3]) {
        m++;
        a[1][0] = ll[i] - 1;
        a[1][1] = ll[i];
      }
    } else {
      if (l[i][2] == l[i][3]) {
        if (l[i][0] == l[i][3]) {
          m++;
          a[0][0] = 2;
          a[0][1] = 1;
        } else {
          m++;
          a[0][0] = 1;
          a[0][1] = 2;
        }
      } else {
        if (l[i][0] == '1') {
          m++;
          a[0][0] = 1;
          a[0][1] = 2;
        } else {
          m++;
          a[0][0] = 2;
          a[0][1] = 1;
        }
        if (l[i][2] == '0') {
          m++;
          a[1][0] = ll[i];
          a[1][1] = ll[i] - 1;
        } else {
          m++;
          a[1][0] = ll[i] - 1;
          a[1][1] = ll[i];
        }
      }
    }
    cout << m << endl;
    if (m == 2) {
      cout << a[0][0] << ' ' << a[0][1] << endl;
      cout << a[1][0] << ' ' << a[1][1] << endl;
    } else {
      if (a[0][0] != 0 || a[0][1] != 0)
        cout << a[0][0] << ' ' << a[0][1] << endl;
      if (a[1][0] != 0 || a[1][1] != 0)
        cout << a[1][0] << ' ' << a[1][1] << endl;
    }
  }
}
