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

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

vector<vector<int>> visvis;

std::vector<std::vector<int>> getVisionPattern2d() {
    return vector<vector<int>>{
        {1, 1, 1, 1, 1, 1, 1, 1},
        {1, 1, 2, 2, 2, 1, 1, 1},
        {1, 1, 1, 1, 1, 1, 2, 1},
        {1, 3, 1, 1, 1, 1, 1, 1}
    };
}
std::pair<int, int> getMove2d(std::vector<std::vector<int>> v) {
    if (v.size() == 3) {
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                if (v[i][j] == 2) {
                    return {i, j};
                }
            }
        }
        return {2, 2};
    }
    int cnt2 = 0;
    pair<int, int> twoInNeir = {-1, -1};
    pair<int, int> justTwo = {-1, -1};
    for (int i = 0; i < 5; ++i) {
        for (int j = 0; j < 5; ++j) {
            if (v[i][j] == 2) {
                if (abs(i - 2) == 1) {
                    twoInNeir = {i, j};
                }
                if (i != 2 || j != 2) {
                    justTwo = {i, j};
                }
                cnt2++;
            }
        }
    }
    if (twoInNeir.first != -1 && cnt2 == 4) {
        return twoInNeir;
    } else if (twoInNeir.first != -1) {
        pair<int, int> res;
        if (twoInNeir.first < 2) {
            res.first = 4;
        } else {
            res.first = 0;
        }
        if (twoInNeir.second < 2) {
            res.second = 4;
        } else {
            res.second = 0;
        }
        return res;
    } else if (justTwo.first != -1) {
        return justTwo;
    } else {
        return {4, 4};
    }
}
