#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    char arr[n][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        cin >> arr[i][j];
      }
    }
    vector<pair<int, int>> v;
    if (arr[0][1] == '1' && arr[1][0] == '0') {
      v.push_back({2, 1});
      if (arr[n - 1][n - 2] == '0') {
        v.push_back({n, n - 1});
      }
      if (arr[n - 2][n - 1] == '0') {
        v.push_back({n - 1, n});
      }
    } else if (arr[0][1] == '0' && arr[1][0] == '1') {
      v.push_back({1, 2});
      if (arr[n - 1][n - 2] == '0') {
        v.push_back({n, n - 1});
      }
      if (arr[n - 1][n - 2] == '0') {
        v.push_back({n - 1, n});
      }
    } else if (arr[0][1] == '0' && arr[1][0] == '0') {
      if (arr[n - 1][n - 2] == '0') {
        v.push_back({n, n - 1});
      }
      if (arr[n - 2][n - 1] == '0') {
        v.push_back({n - 1, n});
      }
    } else if (arr[0][1] == '1' && arr[1][0] == '1') {
      if (arr[n - 1][n - 2] == '1') {
        v.push_back({n, n - 1});
      }
      if (arr[n - 2][n - 1] == '1') {
        v.push_back({n - 1, n});
      }
    }
    cout << v.size() << endl;
    for (int i = 0; i < v.size(); i++) {
      cout << v[i].first << " " << v[i].second << endl;
    }
  }
}
