[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    declare long long n
    input n
    declare char array mat with n and n indices
    loop i through 0 and one less than n
        loop j through 0 and 1 less than n, inputting mat at indices i and j
    set bools col_x and row_x to be false
    loop i between 0 and one less than n
        declare long long cnt to be 0
        loop j from 0 to one less than n
            if mat at i and j is E then increment cnt
        if cnt equals n
            set row_x true
            break
        end of the block
    end of the block
    loop i between 0 and one less than n
        declare long long cnt to be 0
        loop j between 0 and one less than n
            if mat at j and i is E increment cnt
        if cnt equals n
            set col__x to true
            break
        end of the block
    end of the block
    if both col_x and row_x are true
        output -1 and a newline
    otherwise if row_x is true
        loop i from 0 to one less than n
            loop j from 0 to one less than n
                if mat at j and i equals .
                    output j plus 1, a space, i plus one, and a newline
                    break
                end of the block
            end of the block
        end of the block
    else
        loop i from 0 to one less than n
            loop j from 0 to one less than n
                if mat at i and j is .
                    output i plus 1, a space, and j plus 1 and a newline
                    break
                end of the block
            end of the block
        end of the block
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    long long n;
    cin >> n;
    char mat[n][n];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) cin >> mat[i][j];
    bool col_x = false, row_x = false;
    for (int i = 0; i < n; i++) {
        long long cnt = 0;
        for (int j = 0; j < n; j++)
            if (mat[i][j] == 'E') cnt++;
        if (cnt == n) {
            row_x = true;
            break;
        }
    }
    for (int i = 0; i < n; i++) {
        long long cnt = 0;
        for (int j = 0; j < n; j++)
            if (mat[j][i] == 'E') cnt++;
        if (cnt == n) {
            col_x = true;
            break;
        }
    }
    if (col_x && row_x)
        cout << -1 << "\n";
    else if (row_x) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (mat[j][i] == '.') {
                    cout << j + 1 << " " << i + 1 << "\n";
                    break;
                }
            }
        }
    } else {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (mat[i][j] == '.') {
                    cout << i + 1 << " " << j + 1 << "\n";
                    break;
                }
            }
        }
    }
    return 0;
}