#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<numeric>
#include<functional>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>

using namespace std;

//#define int long long
#define pii pair<int, int>
#define ll long long

#define ve vector
#define vi ve<int>
#define vvi ve<vi>
#define tiii tuple<ll, ll, ll>
#define tiiii tuple<int, int, int, int>
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a= max(a, b)
#define all(a) a.begin(), a.end()
#define for0(i, n) for(int i= 0; i < n; ++i)
#define pll pair<ll, ll>

vector<int> getVisionPattern1d() {
    return vi{ 1, 1, 1, 2, 1, 3 };
}
int getMove1d(vector<int> v) {
    if (v[v.size() / 2] == 1) return (v[0] >= v[2] ? 0 : 2);
    else if (v[v.size() / 2] == 2) {
        int i = -1;
        for (int j = 0; j < v.size(); ++j) if (v[j] == 3) i = j;
        return i;
    }
    else return (v[1] == 2 ? 6 : 0);
}
vector<vector<int>> getVisionPattern2d() {
    vvi v(6, vi(6, 1));
    v[1][1] = 2, v[2][4] = 2, v[4][2] = 2, v[5][5] = 3;
    return v;
}
pair<int, int> getMove2d(vector<vector<int>> v) {
    int val = v[v.size() / 2][v.size() / 2];
    if (val == 1) {
        int ti = -1, tj = -1;
        for (int i = 0; i < v.size(); ++i) {
            for (int j = 0; j < v.size(); ++j) {
                if (ti == -1 || v[i][j] > v[ti][tj]) {
                    ti = i; tj = j;
                }
            }
        }
        return { ti, tj };
    }
    else if (val == 2) {
        int ti = -1, tj = -1;
        for (int i = 0; i < v.size(); ++i) {
            for (int j = 0; j < v.size(); ++j) {
                if (v[i][j] == 3) {
                    ti = i; tj = j;
                }
            }
        }
        if(ti != -1) return { 4 - ti, 4 - tj };
        for (int i = 0; i < v.size(); ++i) {
            for (int j = 0; j < v.size(); ++j) {
                if (i == 2 && j == 2) continue;
                if (v[i][j] == 2) {
                    ti = i; tj = j;
                    if (ti == 0 && tj == 4) return { 2, 4 };
                    else if (ti == 0 && tj == 0) return { 2, 0 };
                    else if (ti == 4 && tj == 4) return { 2, 4 };
                    else return { 2, 0 };
                }
            }

        }
    }
    else {
        if (v[5][5] == 2) return { 5, 5 };
        else if (v[1][5] == 2) return { 1, 5 };
        else if (v[5][1] == 2) return { 5, 1 };
        else return { 1, 1 };
    }
}