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

vector<int> getVisionPattern1d() {
    return vector<int>{1, 2, 3, 1};
}
int getMove1d(vector<int> v) {
    if (v.size() == 3) {
        for (int i = 0; i < (int) v.size(); ++i) {
            if (v[i] != 1) {
                return i;
            }
        }
    } else if (v.size() == 5) {
        for (int i = 0; i < (int) v.size(); ++i) {
            if (v[i] == 3) {
                return i;
            }
        }
    } else {
        if (v[4] == 1) {
            return 6;
        } else {
            return 0;
        }
    }
}


std::vector<std::vector<int>> getVisionPattern2d() {
    return vector<vector<int>>{
        {1, 1, 1},
        {1, 1, 2},
        {1, 2, 3}
    };
}
std::pair<int, int> getMove2d(std::vector<std::vector<int>> v) {
    vector<vector<int>> vis = {
        {1, 1, 1},
        {1, 1, 2},
        {1, 2, 3}
    };
    auto getCell = [&](int i, int j) {
        return vis[(i % 3 + 3) % 3][(j % 3 + 3) % 3];
    };
    auto revLines = [&](vector<vector<int>> v) {
        reverse(v.begin(), v.end());
        return v;
    };
    auto revCols = [&](vector<vector<int>> v) {
        for (auto &ln : v) {
            reverse(ln.begin(), ln.end());
        }
        return v;
    };
    auto revAll = [&](vector<vector<int>> v) {
        return revLines(revCols(v));
    };
    auto checkEq = [&](vector<vector<int>> v, int i, int j) {
        if (v[0].size() != getCell(i, j) * 2 + 1) {
            return false;
        }
        for (int shI = -getCell(i, j); shI <= getCell(i, j); ++shI) {
            for (int shJ = -getCell(i, j); shJ <= getCell(i, j); ++shJ) {
                if (getCell(i + shI, j + shJ) != v[shI + getCell(i, j)][shJ + getCell(i, j)]) {
                    return false;
                }
            }
        }
        return true;
    };
    // int ii = -1, jj = -1;
    // int ansI = -1, ansJ = -1;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            if (checkEq(v, i, j)) return {v.size() - 1, v.size() - 1};
            if (checkEq(revCols(v), i, j)) return {v.size() - 1, 0};
            if (checkEq(revLines(v), i, j)) return {0, v.size() - 1};
            if (checkEq(revAll(v), i, j)) return {0, 0};
        }
    }
}
