#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    string s[n];
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    if (s[0][1] == s[1][0]) {
      int cnt1 = 0, cnt2 = 0;
      if (s[n - 1][n - 2] == s[0][1]) {
        cnt1 = 1;
      }
      if (s[n - 2][n - 1] == s[1][0]) {
        cnt2 = 1;
      }
      if (cnt1 == 0 && cnt2 == 0) {
        cout << 0 << endl;
      } else if (cnt1 == 1 && cnt2 == 0) {
        cout << 1 << endl;
        cout << n << " " << n - 1 << endl;
      } else if (cnt1 == 0 && cnt2 == 1) {
        cout << 1 << endl;
        cout << n - 1 << " " << n << endl;
      } else if (cnt1 == 1 && cnt2 == 1) {
        cout << 2 << endl;
        cout << n << " " << n - 1 << endl;
        cout << n - 1 << " " << n << endl;
      }
    } else if (s[n - 1][n - 2] == s[n - 2][n - 1]) {
      int cnt1 = 0, cnt2 = 0;
      if (s[0][1] == s[n - 1][n - 2]) {
        cnt1 = 1;
      }
      if (s[1][0] == s[n - 1][n - 2]) {
        cnt2 = 1;
      }
      if (cnt1 == 0 && cnt2 == 0) {
        cout << 0 << endl;
      } else if (cnt1 == 1 && cnt2 == 0) {
        cout << 1 << endl;
        cout << 1 << " " << 2 << endl;
      } else if (cnt1 == 0 && cnt2 == 1) {
        cout << 1 << endl;
        cout << 2 << " " << endl;
      } else if (cnt1 == 1 && cnt2 == 1) {
        cout << 2 << endl;
        cout << 1 << " " << 2 << endl;
        cout << 2 << " " << 1 << endl;
      }
    } else {
      cout << 2 << endl;
      cout << 1 << " " << 2 << endl;
      if (s[n - 1][n - 2] == s[1][0]) {
        cout << n << " " << n - 1 << endl;
      }
      if (s[n - 2][n - 1] == s[1][0]) {
        cout << n - 1 << " " << n << endl;
      }
    }
  }
  return 0;
}
