#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long T;
  cin >> T;
  while (T--) {
    long long n, i, j;
    cin >> n;
    char s[n][n];
    long long x = 0, y = 0;
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) cin >> s[i][j];
    }
    if (s[0][1] == '0')
      ++x;
    else
      ++y;
    if (s[1][0] == '0')
      ++x;
    else
      ++y;
    if (s[n - 1][n - 2] == '0')
      ++x;
    else
      ++y;
    if (s[n - 2][n - 1] == '0')
      ++x;
    else
      ++y;
    long long z = 0;
    if (x == 4) {
      cout << 2, cout << "\n";
      cout << 1 << " " << 2, cout << "\n";
      cout << 2 << " " << 1, cout << "\n";
    } else if (y == 4) {
      cout << 2, cout << "\n";
      cout << 1 << " " << 2, cout << "\n";
      cout << 2 << " " << 1, cout << "\n";
    } else if (x > y) {
      if (s[1][0] != s[0][1]) {
        cout << 1, cout << "\n";
        if (s[1][0] == '0')
          cout << 2 << " " << 1, cout << "\n";
        else
          cout << 1 << " " << 2, cout << "\n";
      } else {
        cout << 1, cout << "\n";
        if (s[n - 2][n - 1] == '0')
          cout << n - 1 << " " << n, cout << "\n";
        else
          cout << n << " " << n - 1, cout << "\n";
      }
    } else if (y > x) {
      if (s[1][0] != s[0][1]) {
        cout << 1, cout << "\n";
        if (s[1][0] == '1')
          cout << 2 << " " << 1, cout << "\n";
        else
          cout << 1 << " " << 2, cout << "\n";
      } else {
        cout << 1, cout << "\n";
        if (s[n - 2][n - 1] == '0')
          cout << n - 1 << " " << n, cout << "\n";
        else
          cout << n << " " << n - 1, cout << "\n";
      }
    } else if (x == y) {
      if (s[1][0] == s[0][1])
        cout << 0, cout << "\n";
      else {
        cout << 2, cout << "\n";
        if (s[1][0] == '1')
          cout << 2 << " " << 1, cout << "\n";
        else
          cout << 1 << " " << 2, cout << "\n";
        if (s[n - 2][n - 1] == '0')
          cout << n - 1 << " " << n, cout << "\n";
        else
          cout << n << " " << n - 1, cout << "\n";
      }
    }
  }
}
