#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, c, d;
    int n;
    cin >> n;
    string s;
    int i = 1;
    int num = n;
    while (num--) {
      cin >> s;
      if (i == 1) a = s[1] - '0';
      if (i == 2) b = s[0] - '0';
      if (i == n - 1) c = s[n - 1] - '0';
      if (i == n) d = s[n - 2] - '0';
      i++;
    }
    if (a == 0 && b == 0 && c == 0 && d == 0) {
      cout << "2" << endl;
      cout << "1 2" << endl << "2 1" << endl;
    }
    if (a == 0 && b == 0 && c == 0 && d == 1) {
      cout << "1" << endl;
      cout << n - 1 << " " << n << endl;
    }
    if (a == 0 && b == 0 && c == 1 && d == 0) {
      cout << "1" << endl;
      cout << n << " " << n - 1 << endl;
    }
    if (a == 0 && b == 0 && c == 1 && d == 1) {
      cout << "0" << endl;
    }
    if (a == 0 && b == 1 && c == 0 && d == 0) {
      cout << "1" << endl;
      cout << "2 1" << endl;
    }
    if (a == 0 && b == 1 && c == 0 && d == 1) {
      cout << "2" << endl;
      cout << "2 1" << endl << n - 1 << " " << n << endl;
    }
    if (a == 0 && b == 1 && c == 1 && d == 0) {
      cout << "2" << endl;
      cout << "2 1" << endl << n << " " << n - 1 << endl;
    }
    if (a == 0 && b == 1 && c == 1 && d == 1) {
      cout << "1" << endl;
      cout << "2 1" << endl;
    }
    if (a == 1 && b == 0 && c == 0 && d == 0) {
      cout << "1" << endl;
      cout << "2 1" << endl;
    }
    if (a == 1 && b == 0 && c == 0 && d == 1) {
      cout << "2" << endl;
      cout << "2 1" << endl << n << " " << n - 1 << endl;
    }
    if (a == 1 && b == 0 && c == 1 && d == 0) {
      cout << "2" << endl;
      cout << "2 1" << endl << n - 1 << " " << n << endl;
    }
    if (a == 1 && b == 0 && c == 1 && d == 1) {
      cout << "1" << endl;
      cout << "1 2" << endl;
    }
    if (a == 1 && b == 1 && c == 0 && d == 0) {
      cout << "0" << endl;
    }
    if (a == 1 && b == 1 && c == 0 && d == 1) {
      cout << "1" << endl;
      cout << n << " " << n - 1 << endl;
    }
    if (a == 1 && b == 1 && c == 1 && d == 0) {
      cout << "1" << endl;
      cout << n - 1 << " " << n << endl;
    }
    if (a == 1 && b == 1 && c == 1 && d == 1) {
      cout << "2" << endl;
      cout << "1 2" << endl << "2 1" << endl;
    }
  }
  return 0;
}
