#include "vision.h"
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define ll long long
#define MP make_pair
using namespace std;
const int N=2e5+5;

vector<int> getVisionPattern1d()
{
    return {3,1,1,1,2,1,2,2,1,1};
}
int getMove1d(vector<int> v)
{
    int x=(int)v.size()/2;
    if(x==1)
    {
        if(v[0]==v[2]) return 0;
        return (v[2]==1 ? 0:2);
    }
    else if(x==2)
    {
        if(v[x+1]==1&&v[x+2]==1)
        {
            if(v[x-1]==1) return x-2;
            else return x+2;
        }
        if(v[x-1]==1&&v[x-2]==1)
        {
            if(v[x+1]==1) return x+2;
            else return x-2;
        }
        if(v[x+1]==2) return x+1;
        else return x-1;
    }
    else if(x==3)
    {
        if(v[x+3]==1) return x+3;
        else return x-3;
    }
}

vector<vector<int>> getVisionPattern2d()
{
    return {{3,1,1,1,2,1,2,2,1,1}};
}
pair<int,int> getMove2d(vector<vector<int>> v)
{
    int x=(int)v.size()/2;
    if(x==1)
    {
        if(v[0][0]==v[0][2]) return MP(0,0);
        return MP(0,(v[0][2]==1 ? 0:2));
    }
    else if(x==2)
    {
        if(v[0][x+1]==1&&v[0][x+2]==1)
        {
            if(v[0][x-1]==1) return MP(0,x-2);
            else return MP(0,x+2);
        }
        if(v[0][x-1]==1&&v[0][x-2]==1)
        {
            if(v[0][x+1]==1) return MP(0,x+2);
            else return MP(0,x-2);
        }
        if(v[0][x+1]==2) return MP(0,x+1);
        else return MP(0,x-1);
    }
    else if(x==3)
    {
        if(v[0][x+3]==1) return MP(0,x+3);
        else return MP(0,x-3);
    }
}
