#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    char ar[n][n];
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) cin >> ar[i][j];
    if (ar[1][2] == '0' && ar[2][1] == '0') {
      if (ar[n][n - 1] == '0' && ar[n - 1][n] == '0') {
        cout << "2" << endl;
        cout << n << " " << n - 1 << endl;
        cout << n - 1 << " " << n << endl;
      }
      if (ar[n][n - 1] == '1' && ar[n - 1][n] == '1') {
        cout << "0" << endl;
      } else {
        if (ar[n][n - 1] == '0')
          cout << 1 << endl << n << " " << n - 1 << endl;
        else
          cout << 1 << endl << n - 1 << " " << n << endl;
      }
    } else if (ar[1][2] == '1' && ar[2][1] == '1') {
      if (ar[n][n - 1] == '0' && ar[n - 1][n] == '0') {
        cout << "0" << endl;
      } else if (ar[n][n - 1] == '1' && ar[n - 1][n] == '1') {
        cout << "2" << endl;
        cout << n << " " << n - 1 << endl;
        cout << n - 1 << " " << n << endl;
      } else {
        if (ar[n][n - 1] == '1')
          cout << 1 << endl << n << " " << n - 1 << endl;
        else
          cout << 1 << endl << n - 1 << " " << n << endl;
      }
    } else {
      if (ar[n][n - 1] == '0' && ar[n - 1][n] == '0') {
        if (ar[1][2] == '0')
          cout << 1 << endl << 1 << " " << 2 << endl;
        else
          cout << 1 << endl << 2 << " " << 1 << endl;
      } else if (ar[n][n - 1] == '1' && ar[n - 1][n] == '1') {
        if (ar[1][2] == '1')
          cout << 1 << endl << 1 << " " << 2 << endl;
        else
          cout << 1 << endl << 2 << " " << 1 << endl;
      } else {
        cout << 2 << endl;
        if (ar[1][2] == '1')
          cout << 1 << " " << 2 << endl;
        else
          cout << 2 << " " << 1 << endl;
        if (ar[n][n - 1] == '0')
          cout << n << " " << n - 1 << endl;
        else
          cout << n - 1 << " " << n << endl;
      }
    }
  }
  return 0;
}
