#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int test;
  cin >> test;
  while (test--) {
    int n;
    cin >> n;
    char array[n][n];
    int i, j;
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        cin >> array[i][j];
      }
    }
    int a = int(array[0][1]) - 48;
    int b = int(array[1][0]) - 48;
    int c = int(array[n - 2][n - 1]) - 48;
    int d = int(array[n - 1][n - 2]) - 48;
    int sum = a + b;
    int sum_2 = c + d;
    if (sum == 0 && sum_2 == 0) {
      cout << 2 << "\n";
      cout << 1 << " " << 2 << "\n";
      cout << 2 << " " << 1 << "\n";
    }
    if (sum == 0 && sum_2 == 1) {
      cout << 1 << "\n";
      if (array[n - 2][n - 1] == '1') {
        cout << n - 1 << " " << n << "\n";
      } else {
        cout << n << " " << n - 1 << "\n";
      }
    }
    if (sum == 0 && sum_2 == 2) {
      cout << 0 << "\n";
    }
    if (sum == 1 && sum_2 == 0) {
      cout << 1 << "\n";
      if (array[1][0] == '1') {
        cout << 2 << " " << 1 << "\n";
      } else {
        cout << 1 << " " << 2 << "\n";
      }
    }
    if (sum == 1 && sum_2 == 1) {
      cout << 2 << "\n";
      if (array[1][0] == '1') {
        cout << 2 << " " << 1 << "\n";
      } else {
        cout << 1 << " " << 2 << "\n";
      }
      if (array[n - 2][n - 1] == '1') {
        cout << n << " " << n - 1 << "\n";
      } else {
        cout << n - 1 << " " << n << "\n";
      }
    }
    if (sum == 1 && sum_2 == 2) {
      cout << 1 << "\n";
      if (array[1][0] == '1') {
        cout << 2 << " " << 1 << "\n";
      } else {
        cout << 1 << " " << 2 << "\n";
      }
    }
    if (sum == 2 && sum_2 == 0) {
      cout << 0 << "\n";
    }
    if (sum == 2 && sum_2 == 1) {
      cout << 1 << "\n";
      if (array[n - 2][n - 1] == '1') {
        cout << n - 1 << " " << n << "\n";
      } else {
        cout << n << " " << n - 1 << "\n";
      }
    }
    if (sum == 2 && sum_2 == 2) {
      cout << 2 << "\n";
      cout << 1 << " " << 2 << "\n";
      cout << 2 << " " << 1 << "\n";
    }
  }
  return 0;
}
