#include <bits/stdc++.h>
using namespace std;
char map[205][205];
int r1[5];
int c1[5];
int r2[5];
int c2[5];
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) cin >> map[i][j];
    int top1 = 0, top2 = 0;
    for (int i = 0; i < 3; i++)
      for (int j = 0; j <= i; j++) {
        if (i == 0 && j == 0) continue;
        if (i + j == 1) {
          if (map[i][j] - '0' != 0) {
            r1[top1] = i, c1[top1] = j;
            top1++;
          }
        } else if (i + j == 2) {
          if (map[i][j] - '0' != 1) {
            r1[top1] = i, c1[top1] = j;
            top1++;
          }
        }
      }
    for (int i = 0; i < 3; i++)
      for (int j = 0; j <= i; j++) {
        if (i == 0 && j == 0) continue;
        if (i + j == 1) {
          if (map[i][j] - '0' != 1) {
            r2[top2] = i, c2[top2] = j;
            top2++;
          }
        } else if (i + j == 2) {
          if (map[i][j] - '0' != 0) {
            r2[top2] = i, c1[top2] = j;
            top2++;
          }
        }
      }
    if (top1 <= 2) {
      cout << top1 << endl;
      for (int i = 0; i < top1; i++) cout << r1[i] << " " << c1[i] << endl;
    } else if (top2 <= 2) {
      cout << top2 << endl;
      for (int i = 0; i < top2; i++) cout << r2[i] << " " << c2[i] << endl;
    }
  }
  return 0;
}
