#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    char s[n][n];
    vector<int> coordinates = {};
    int count = 0;
    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 - 2][n - 1] == '0') {
        count++;
        coordinates.push_back(n - 1);
        coordinates.push_back(n);
      }
      if (s[n - 1][n - 2] == '0') {
        count++;
        coordinates.push_back(n);
        coordinates.push_back(n - 1);
      }
    } else if (s[0][1] == '1' && s[1][0] == '1') {
      if (s[n - 2][n - 1] == '1') {
        count++;
        coordinates.push_back(n - 1);
        coordinates.push_back(n);
      }
      if (s[n - 1][n - 2] == '1') {
        count++;
        coordinates.push_back(n);
        coordinates.push_back(n - 1);
      }
    } else if (s[0][1] == '1' && s[1][0] == '0') {
      count++;
      coordinates.push_back(1);
      coordinates.push_back(2);
      if (s[n - 2][n - 1] == '0') {
        count++;
        coordinates.push_back(n - 1);
        coordinates.push_back(n);
      }
      if (s[n - 1][n - 2] == '0') {
        count++;
        coordinates.push_back(n);
        coordinates.push_back(n - 1);
      }
    } else if (s[0][1] == '0' && s[1][0] == '1') {
      count++;
      coordinates.push_back(2);
      coordinates.push_back(1);
      if (s[n - 2][n - 1] == '0') {
        count++;
        coordinates.push_back(n - 1);
        coordinates.push_back(n);
      }
      if (s[n - 1][n - 2] == '0') {
        count++;
        coordinates.push_back(n);
        coordinates.push_back(n - 1);
      }
    }
    cout << count << endl;
    for (int i = 0; i < coordinates.size(); i += 2) {
      cout << coordinates[i] << " " << coordinates[i + 1] << endl;
    }
  }
}
