#include using namespace std; int main(){ int N; cin >> N; vector S(N); for (int i = 0; i < N; i++){ cin >> S[i]; } auto op = [&](int r, int c){ S[r][c] ^= '.' ^ '#'; S[(N + r - 1) % N][c] ^= '.' ^ '#'; S[r][(N + c - 1) % N] ^= '.' ^ '#'; S[(N + r - 1) % N][(N + c - 1) % N] ^= '.' ^ '#'; }; vector> ans; for (int i = 1; i < N; i++){ for (int j = 1; j < N; j++){ if (S[i - 1][j - 1] == '#'){ ans.push_back(make_pair(i, j)); op(i, j); op(i, 0); op(0, j); } } } for (int i = 1; i < N; i += 2){ if (S[i][0] == '#'){ for (int j = 0; j < N; j++){ ans.push_back(make_pair(i, j)); op(i, j); op(i, 0); op(0, j); } } if (S[0][i] == '#'){ for (int j = 0; j < N; j++){ ans.push_back(make_pair(j, i)); op(j, i); op(j, 0); op(0, i); } } } if (S[0][0] == '#'){ ans.push_back(make_pair(0, 0)); op(0, 0); } bool ok = true; for (int i = 0; i < N; i++){ for (int j = 0; j < N; j++){ if (S[i][j] == '#'){ ok = false; } } } if (ok){ cout << ans.size() << endl; for (auto [R, C] : ans){ cout << R << ' ' << C << endl; } } else { cout << -1 << endl; } }