#include <bits/stdc++.h>

using namespace std;

vector<int> getVisionPattern1d() {
    int m = 40;
    vector<int> res(m);
    for (int i = 0; i < m; i += 5) {
        res[i] = 2;
        res[i + 1] = 1;
        res[i + 2] = 3;
        res[i + 3] = 1;
        res[i + 4] = 1;
    }
    return res;
}

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

vector<vector<int>> getVisionPattern2d() {
}

pair<int, int> getMove2d(vector<vector<int>> v) {
}