[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 length 120 by 120
in function check that returns an integer and takes argument n = integer
    flag1 = integer
    for i = 1 to n inclusive
        set flag1 to 0
        for j = 1 to n inclusive
            if a[i][j] equals .
                set flag1 to 1
                break
            end of the block
        end of the block
        if not flag1 then break
    end of the block
    flag2 = integer
    for i = 1 to n inclusive
        set flag2 to 0
        for j = 1 to n inclusive
            if a[j][i] equals .
                set flag2 to 1
                break
            end of the block
        end of the block
        if not flag2 then break
    end of the block
    if flag1 and flag2 both equal 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 inclusive
            for j = 1 to n inclusive read a[i][j]
        end of the block
        judge = integer with value of the return of function check with argument n
        if judge is not 0
            if judge equals 1
                for i = 1 to n inclusive
                    for j = 1 to n inclusive
                        if a[i][j] equals .
                            print i space j
                            break
                        end of the block
                    end of the block
                end of the block
            else
                for i = 1 to n inclusive
                    for j = 1 to n inclusive
                        if a[j][i] equals .
                            print j space i
                            break
                        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;
        }
    }
}