#include<bits/stdc++.h>

#define ll long long
#define begin begin()
#define end end()
#define pb push_back
#define in insert
#define lldef ll N=0,M=0,K=0;
#define mk make_pair

using namespace std;
vector<ll>x={0,1,-1};
vector<ll>y={0,1,-1};
vector<int> getVisionPattern1d(){
    vector<int>ANS={1,2,1,1,2,2};
    return ANS;
}
int getMove1d(vector<int> v){
    ll N=v.size();
    ll mid=v[(N-1)/2];
    ll md=(N-1)/2;
    if(mid==2){
        if(v[md+1]==2 and v[md-2]!=2){
            return md+1;
        }else if(v[md-1]==2 and v[md+2]!=2){
            return md-1;
        }
        if(v[md-1]==2 and v[md+2]==2){
            return md+2;
        }else if(v[md+1]==2 and v[md-2]==2){
            return md-2;
        }
        if(v[md-2]==2){
            return md+2;
        }else if(v[md+2]==2){
            return md-2;
        }
    }else{
        if(v[md+1]==2){
            return md+1;
        }else{
            return md-1;
        }
    }
    return 0;
}
vector<vector<int>> getVisionPattern2d(){
    vector<vector<int>>ANS={{1,1,1},{1,1,1},{3,1,1},{1,1,1},{1,1,2}};
    return ANS;
}
pair<int, int> getMove2d(vector<vector<int>> v){
    ll N=v[0].size();
    ll md=(N-1)/2;
    ll mid=v[md][md];
    if(mid==1){
        for(ll i=0; i<3; i++){
            for(ll j=0; j<3; j++){
                if(v[md+x[i]][md+y[j]]!=1){
                    return mk(md+x[i],md+y[j]);
                }
            }
        }
    }else if(mid==2){
        if(v[0][3]==3){
            return mk(0,3);
        }
        if(v[0][1]==3){
            return mk(0,1);
        }
        if(v[4][3]==3){
            return mk(4,3);
        }
        if(v[4][1]==3){
            return mk(4,1);
        }
    }else if (mid==3){
        if(v[md-2][md+2]==2){
            return mk(md-2,md+2);
        }
        if(v[md-2][md-2]==2){
            return mk(md-2,md-2);
        }
        if(v[md+2][md+2]==2){
            return mk(md+2,md+2);
        }
        if(v[md+2][md-2]==2){
            return mk(md+2,md-2);
        }
    }
}