#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ar array
#define all(v) v.begin(), v.end()

const int N = 1e5 + 20;
const int MOD = 1e9 + 7;
const int INF = 1e16;

template<typename T>
void chmin(T &a, T b){a = min(a, b);};
template<typename T>
void chmax(T &a, T b){a = max(a, b);};
template<typename T>
void mm(T &x){
    x %= MOD;
    if (x < 0) x += MOD;
};
std::vector<int> getVisionPattern1d(){
    return {3, 1, 1, 1, 2, 1, 2, 1};
}

int getMove1d(std::vector<int> v){
    if(v.size() == 3){
        if (v[0] > v[2])return 0;
        return 2;
    }else if(v.size() == 5){
        if (v[0] > v[4])return 0;
        return 4;
    }else{
        if (v[0] == 1 && v[1] == 1)return 0;
        return 6;
    }
    return 0;
}

std::vector<std::vector<int>> getVisionPattern2d()
{
    vector<vector<int> > v(4, vector<int>(4, 1));
    v[0][0] = 3;
    v[3][0] = 3;
    v[0][3] = 3;
    v[3][3] = 2;
    return v;
}

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] == 3)return {i, j};
            }
        }
        for (int i = 0;i < 3;i++) {
            for (int j = 0;j < 3;j++) {
                if (v[i][j] == 2)return {i, j};
            }
        }
        return {0, 0};
    }else if (v.size() == 5) {
        for (auto i: {1, 3}) {
            for (auto j: {1, 3}) {
                if (v[i][j] == 3)return {i, j};
            }
        }
        return {0, 0};
    }else {
        for (auto i: {0, 6}) {
            for (auto j: {0, 6}) {
                if (v[i][j] == 2)return {i, j};
            }
        }
        if (v[3][6] == 2)return {3, 6};
        if (v[3][0] == 2)return {3, 0};
        if (v[0][3])return {0, 3};
        if (v[6][3])return {6, 3};
    }
}
