#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, c = 0;
    cin >> n;
    char s[n][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        cin >> s[i][j];
      }
    }
    if (s[0][1] == '0' && s[1][0] == '0') {
      if (s[n - 1][n - 2] == '0') {
        if (s[n - 2][n - 1] == '0') {
          cout << 2 << endl;
          cout << n << " " << n - 1 << endl;
          cout << n - 1 << " " << n << endl;
        } else {
          cout << 1 << endl;
          cout << n << " " << n - 1;
        }
      } else {
        cout << 1 << endl;
        cout << n - 1 << " " << n << endl;
      }
    } else if (s[0][1] == '1' && s[1][0] == '1') {
      if (s[n - 1][n - 2] == '1') {
        if (s[n - 2][n - 1] == '1') {
          cout << 2 << endl;
          cout << n << " " << n - 1 << endl;
          cout << n - 1 << " " << n << endl;
        } else {
          cout << 1 << endl;
          cout << n << " " << n - 1;
        }
      } else {
        cout << 1 << endl;
        cout << n - 1 << " " << n << endl;
      }
    } else {
      c = (s[0][2] == '1') + (s[1][1] == '1') + (s[2][0] == '1');
      if (c == 1) {
        cout << 2 << endl;
        if (s[0][1] == '0') {
          cout << 1 << " " << 2 << endl;
        } else {
          cout << 2 << " " << 1 << endl;
        }
        if (s[2][0] == '1') {
          cout << 3 << " " << 1 << endl;
        } else if (s[1][1] == '1') {
          cout << 2 << " " << 2 << endl;
        } else {
          cout << 1 << " " << 3 << endl;
        }
      } else if (c == 2) {
        cout << 2 << endl;
        if (s[0][1] == '1') {
          cout << 1 << " " << 2 << endl;
        } else {
          cout << 2 << " " << 1 << endl;
        }
        if (s[2][0] == '0') {
          cout << 3 << " " << 2 << endl;
        } else if (s[1][1] == '0') {
          cout << 2 << " " << 2 << endl;
        } else {
          cout << 1 << " " << 3 << endl;
        }
      } else if (c == 0) {
        cout << 1 << endl;
        if (s[0][1] == '1') {
          cout << 1 << " " << 2 << endl;
        } else {
          cout << 2 << " " << 1 << endl;
        }
      } else {
        cout << 1 << endl;
        if (s[0][1] == 0) {
          cout << 1 << " " << 2 << endl;
        } else {
          cout << 2 << " " << 1 << endl;
        }
      }
    }
  }
}
