[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]:
a = character array of size 120
in the function check that takes integer n and returns integer
    flag1 = integer
    for i = 1 to n
        flag1 = 0
        for j = 1 to n
            if a[i][j] is .
                flag1 = 1
                break loop
            end of the block
        end of the block
        if not flag1, break loop
    end of the block
    flag2 = integer
    for i = 1 to n
        flag2 = 0
        for j = 1 to n
            if a[j][i] is .
                flag2 = 1
                break loop
            end of the block
        end of the block
        if not flag2, break loop
    end of the block
    if flag1 is 0 and flag2 is 0
        return to indicate successful execution
    else
        if flag1
            return 1
        else
            return 2
        end of the block
    end of the block
end of the block
define the main function
    n = integer
    while read n
        for i = 1 to n
            for j = 1 to n, read a[i][j]
        end of the block
        judge = integer with judge = check on n
        if judge
            if judge is 1
                for i = 1 to n
                    for j = 1 to n
                        if a[i][j] is .
                            print i," ",j
                            break loop
                        end of the block
                    end of the block
                end of the block
            else
                for i = 1 to n
                    for j = 1 to n
                        if a[j][i] is .
                            print j," ",i
                            break loop
                        end of the block
                    end of the block
                end of the block
            end of the block
        else
            print -1
        end of the block
    end of the block
end of the block

[CODE]:

char a[120][120];
int check(int n) {
    int flag1;
    for (int i = 1; i <= n; i++) {
        flag1 = 0;
        for (int j = 1; j <= n; j++) {
            if (a[i][j] == '.') {
                flag1 = 1;
                break;
            }
        }
        if (!flag1) { break; }
    }
    int flag2;
    for (int i = 1; i <= n; i++) {
        flag2 = 0;
        for (int j = 1; j <= n; j++) {
            if (a[j][i] == '.') {
                flag2 = 1;
                break;
            }
        }
        if (!flag2) { break; }
    }
    if (flag1 == 0 && flag2 == 0) {
        return 0;
    } else {
        if (flag1) {
            return 1;
        } else {
            return 2;
        }
    }
}
int main() {
    int n;
    while (cin >> n) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) { cin >> a[i][j]; }
        }
        int judge = check(n);
        if (judge) {
            if (judge == 1) {
                for (int i = 1; i <= n; i++) {
                    for (int j = 1; j <= n; j++) {
                        if (a[i][j] == '.') {
                            cout << i << " " << j << endl;
                            break;
                        }
                    }
                }
            } else {
                for (int i = 1; i <= n; i++) {
                    for (int j = 1; j <= n; j++) {
                        if (a[j][i] == '.') {
                            cout << j << " " << i << endl;
                            break;
                        }
                    }
                }
            }
        } else {
            cout << "-1" << endl;
        }
    }
}