#include <bits/stdc++.h>
using namespace std;
bool flag = 0, flag1 = 0, flag2 = 0, flag3 = 0, flag4 = 0, flag5 = 0;
int main() {
  long long int t = 1;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    string s[n];
    for (int i = 0; i < n; i++) cin >> s[i];
    char a = s[0][1];
    char b = s[1][0];
    char c = s[(int)n - 1][(int)n - 2];
    char d = s[(int)n - 2][(int)n - 1];
    if ((a == '1' && b == '1' && c == '0' && d == '0') ||
        (a == '0' && b == '0' && c == '1' && d == '1'))
      cout << 0 << "\n";
    else {
      if (a == '0') {
        if (b == '0') {
          if (c == '0' && d == '0') {
            cout << 2 << "\n";
            cout << n - 1 << " " << n << "\n";
            cout << n << " " << n - 1 << "\n";
          } else if (c == '1' && d == '0') {
            cout << 1 << "\n";
            cout << n - 1 << " " << n << "\n";
          } else if (c == '0' && d == '1') {
            cout << 1 << "\n";
            cout << n << " " << n - 1 << "\n";
          }
        } else {
          if (c == '0' && d == '0') {
            cout << 1 << "\n";
            cout << 1 << " " << 2 << "\n";
          } else if (c == '1' && d == '0') {
            cout << 2 << "\n";
            cout << 1 << " " << 2 << "\n";
            cout << n << " " << n - 1 << "\n";
          } else if (c == '0' && d == '1') {
            cout << 2 << "\n";
            cout << 1 << " " << 2 << "\n";
            cout << n - 1 << " " << n << "\n";
          }
        }
      } else {
        if (b == '0') {
          if (c == '0' && d == '0') {
            cout << 1 << "\n";
            cout << 2 << " " << 1 << "\n";
          } else if (c == '1' && d == '0') {
            cout << 2 << "\n";
            cout << 1 << " " << 2 << "\n";
            cout << n - 1 << " " << n << "\n";
          } else if (c == '0' && d == '1') {
            cout << 2 << "\n";
            cout << 1 << " " << 2 << "\n";
            cout << n << " " << n - 1 << "\n";
          }
        } else {
          if (c == '1' && d == '1') {
            cout << 2 << "\n";
            cout << n - 1 << " " << n << "\n";
            cout << n << " " << n - 1 << "\n";
          } else if (c == '1' && d == '0') {
            cout << 1 << "\n";
            cout << n << " " << n - 1 << "\n";
          } else if (c == '0' && d == '1') {
            cout << 1 << "\n";
            cout << n - 1 << " " << n << "\n";
          }
        }
      }
    }
  }
  return 0;
}
