#include "vision.h"
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const ll esim = (1 << 30) - 1;
int a[111];
int pw[100];
bool eq(vector<int> a, vector<int> b) {
    return a == b;
}
vector<int> getVisionPattern1d() {
    return { 3, 1, 2, 1, 1 };
}
vector<vector<int>> getVisionPattern2d() {
    return {
        { 2, 1, 2 },
        { 1, 1, 2 },
        { 1, 1, 1 }
    };
}
int getMove1d(vector<int> v) {
    if (eq(v, { 2, 1, 1, 3, 1, 2, 1 })) return 6;
    if (eq(v, { 1, 2, 1, 3, 1, 1, 2 })) return 0;
    if (eq(v, { 3, 1, 2 })) return 2;
    if (eq(v, { 2, 1, 3 })) return 0;
    if (eq(v, {3, 1, 2, 1, 1})) return 4;
    if (eq(v, {1, 1, 2, 1, 3})) return 0;
    if (eq(v, {2, 1, 1})) return 2;
    if (eq(v, {1, 1, 2})) return 0;
    if (eq(v, {1, 1, 3})) return 2;
    return 0;
}
pair<int, int> getMove2d(vector<vector<int>> v) {
    vector<vector<int>> w = {
        { 2, 1, 2 },
        { 1, 1, 2 },
        { 1, 1, 1 }
    };
    vector<vector<int>> ans(15);
    for (int i = 0; i < 15; i++) {
        ans[i].resize(15);
    }
    for (int i = 0; i < 15; i++) {
        for (int j = 0; j < 15; j++) {
            ans[i][j] = w[i % 3][j % 3];
        }
    }
    map <vector<vector<int>>, pair<int, int>> mp;
    for (int i = 5; i < 8; i++) {
        for (int j = 5; j < 8; j++) {
            vector<vector<int>> cur(2 * ans[i][j] + 1);
            for (auto &it : cur) {
                it.resize(2 * ans[i][j] + 1);
            }
            for (int l = -ans[i][j]; l <= ans[i][j]; l++) {
                for (int k = -ans[i][j]; k <= ans[i][j]; k++) {
                    cur[l + ans[i][j]][k + ans[i][j]] = ans[l + ans[i][j]][k + ans[i][j]];
                }
            }
            mp[cur] = { 2 * ans[i][j], 2 * ans[i][j] };
            for (auto &it : cur) reverse(it.begin(), it.end());
            mp[cur] = { 2 * ans[i][j], 0 };
            for (int k = 0; k < ans[i][j]; k++) {
                for (int l = 0; l <= 2 * ans[i][j]; l++) {
                    swap(cur[k][l], cur[2 * ans[i][j] - k][l]);
                }
            }
            mp[cur] = { 0, 0 };
            for (auto &it : cur) reverse(it.begin(), it.end());
            mp[cur] = { 0, 2 * ans[i][j] };
        }
    }
    return mp[v];
}
/*
int main() {
    pair <int, int> k = getMove2d({{2, 1, 2}, {2, 1, 1}, {1, 1, 1 }});
    cout << k.first << " " << k.second << "\n";
}
*/