#include <bits/stdc++.h>
using namespace std;
int n;
void solve() {
  cin >> n;
  vector<int> c;
  int matrix[n][n];
  for (int i = 0; i < n; i++) {
    string line;
    cin >> line;
    for (int j = 0; j < n; j++) {
      matrix[i][j] = line[j] - '0';
    }
  }
  int bottom;
  int sum1 = matrix[1][0] + matrix[0][1];
  int sum2 = matrix[n - 1][n - 2] + matrix[n - 2][n - 2];
  if (sum1 == 2) {
    bottom = 0;
  } else if (sum1 == 0) {
    bottom = 1;
  } else {
    c.push_back(2);
    c.push_back(1);
    bottom = matrix[1][0];
  }
  if (matrix[n - 1][n - 2] != bottom) {
    c.push_back(n);
    c.push_back(n - 1);
  }
  if (matrix[n - 2][n - 1] != bottom) {
    c.push_back(n - 1);
    c.push_back(n);
  }
  cout << c.size() / 2 << "\n";
  for (int i = 0; i < c.size(); i += 2) {
    cout << c[i] << " " << c[i + 1] << "\n";
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  for (int tc = 1; tc <= t; tc++) {
    solve();
  }
}
