#include <bits/stdc++.h>
using namespace std;

std::vector<int> getVisionPattern1d() {
    return {1, 3, 1, 1, 1, 2};
}

int getMove1d(std::vector<int> v) {
    int mid = ((int)v.size()) / 2;
    int n = (int)v.size();
    if (v[mid] == 1) {
        for (int i = 0; i < n; ++i) if (v[i] == 3) return i;
        for (int i = 0; i < n; ++i) if (v[i] == 2) return i;
        return 0;
    }
    if (v[mid] == 2) {
        for (int i = 0; i < n; ++i) if (v[i] == 3) return i;
    }
    else {
        if (v[1] == 2) return n - 1;
        else return 0;
    }
}

std::vector<std::vector<int>> getVisionPattern2d() {
    return {{1, 2, 3}, {3, 1, 2}, {2, 3, 1}};
}
vector<int> dx = {1, -1, 0, 0};
vector<int> dy = {0, 0, 1, -1};

std::pair<int, int> getMove2d(std::vector<std::vector<int>> v) {
    int m = (int)v.size() / 2;
    if (v[m][m] == 1) {
        for (int i = 0; i < 4; ++i) {
            int ni = m + dx[i], nj = m + dy[i];
            if (v[ni][nj] == 2) return {ni, nj};
        }
    }
    if (v[m][m] == 2) {
        int t1 = 0, t2 = 0;
        if (v[m - 1][m] == 3) t1 ^= 1;
        if (v[m][m - 1] == 3) t2 ^= 1;
        int n = (int)v.size();
        int fi = 0, fj = (int)v.size();
        if (t1) fi = n - fi;
        if (t2) fj = n - fj;
        return {fi, fj};
    }
    else {
        int t1 = 0, t2 = 0;
        if (v[m - 1][m] == 1) t1 ^= 1;
        if (v[m][m - 1] == 1) t2 ^= 1;
        int n = (int)v.size();
        int fi = 0, fj = (int)v.size();
        if (t1) fi = n - fi;
        if (t2) fj = n - fj;
        return {fi, fj};
    }
}
#ifdef LOCAL
int main () {

}
#endif // LOCAL
