[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]:
bigmod is a long long function with long long arguments a, b and m
    if b = 0, return 1 % m
    create long long x = bigmod(a, b / 2, m)
    set x to x squared modulo m
    if b is odd, assign (x * a) modulo m to x
    return x
end of the block
define the main function
    declare integer variable n
    read n
    declare string array s with size n + 2
    for i from 0 to n exclusive, read s[i]
    let r and c be vectors of integers arrays with size n + 1
    for i = 0 to n exclusive
        for j from 0 to n exclusive
            if s[i][j] = '.'
                push j to r[i]
                push i to c[j]
            end of the block
    declare integer p = 1
    loop i from 0 to n exclusive
        if r[i] is empty
            change p to 0
            break the loop
        end of the block
    end of the block
    if p is true
        for integer i = 0 to n exclusive, print i + 1, " " and r[i][0] + 1
        return to indicate successful execution
    end of the block
    set p to 1
    for i = 0 to n exclusive
        if c[i] is empty
            change p to 0
            break
        end of the block
    end of the block
    if p is true
        loop i from 0 to n exclusive, print c[i][0] + 1, " " and i + 1
        return to indicate successful execution
    end of the block
    print "-1"
end of the block

[CODE]:

long long bigmod(long long a, long long b, long long m) {
    if (b == 0) return 1 % m;
    long long x = bigmod(a, b / 2, m);
    x = (x * x) % m;
    if (b % 2) x = (x * a) % m;
    return x;
}
int main() {
    int n;
    cin >> n;
    string s[n + 2];
    for (int i = 0; i < n; i++) cin >> s[i];
    vector<int> r[n + 1], c[n + 1];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if (s[i][j] == '.') {
                r[i].push_back(j);
                c[j].push_back(i);
            }
    int p = 1;
    for (int i = 0; i < n; i++) {
        if (r[i].empty()) {
            p = 0;
            break;
        }
    }
    if (p) {
        for (int i = 0; i < n; i++) cout << i + 1 << " " << r[i][0] + 1 << endl;
        return 0;
    }
    p = 1;
    for (int i = 0; i < n; i++) {
        if (c[i].empty()) {
            p = 0;
            break;
        }
    }
    if (p) {
        for (int i = 0; i < n; i++) cout << c[i][0] + 1 << " " << i + 1 << endl;
        return 0;
    }
    puts("-1");
}