#include<bits/stdc++.h>
using namespace std;
std::vector<int> getVisionPattern1d(){
}

int getMove1d(std::vector<int> v){

}
std::vector<std::vector<int>> getVisionPattern2d(){
    int n = 7, m = 7;
    vector<vector<int>> a;
    a.resize(n);
    for(int i = 0; i < n; i++){
        a[i].resize(m);
        for(int j = 0; j < m; j++){
            a[i][j] = 1;
        }
    }
    a[0][0] = 3;
    a[4][1] = 2;
    a[1][4] = 2;
    a[3][3] = 2;
    a[6][2] = 2;
    a[2][6] = 2;
    a[5][5] = 2;
    return a;

}
std::pair<int, int> getMove2d(std::vector<std::vector<int>> v){
    int n = v.size()/2;
    vector<pair<int, int>> x2;
    vector<pair<int, int>> x3;
    for(int i = 0; i < v.size(); i++){
        for(int j = 0; j < v[i].size(); j++){
            if(i == 0 && j == 0){
                continue;
            }
            if(v[i][j] == 2){
                x2.push_back({i, j});
            }
            if(v[i][j] == 3){
                x3.push_back({i , j});
            }

        }
    }
    int s3 = x3.size();
    int s2 = x2.size();
    for(int i = 0; i < v.size(); i++){

    }
    if(v.size() == 3){
            if(s2 != 0){
                return x2[0];
            }
        return {2,1};
    }
    if(v.size() == 7){
        if(v[6][6] == 2) return {6, 6};
        if(v[0][6] == 2) return {0, 6};
        if(v[6][0] == 2) return {6, 0};
        if(v[0][0] == 2) return {0, 0};
    }
    ///v.size == 5
    if(s3 == 1 && s2 == 0) return x3[0];
    if(s3 == 1 && s2 == 2){
        return {v.size() - x3[0].first - 1, v.size() - x3[0].second - 1};
    }
    if(s2 == 3) {
        std::pair<int, int> cor;

        if(v[0][0] == 2){
            cor.first = 0;
            cor.second = 0;
        }
        if(v[4][0] == 2){
            cor.first = 4;
            cor.second = 0;
        }
        if(v[0][4] == 2){
            cor.first = 0;
            cor.second = 4;
        }
        if(v[4][4] == 2){
            cor.first = 4;
            cor.second = 4;
        }
        int cl = 1;
        for(int i= 0; i < x2.size(); i++){
            if(x2[i].first == n){
                continue;
            }
            if(x2[i].first == cor.first){
                continue;
            }
            cl*= (x2[i].first - n)*(x2[i].second - n);
        }
        if(cl > 0){
            return cor;
        }
        for(int i= 0; i < x2.size(); i++){
            if(x2[i].first == n){
                continue;
            }
            if(x2[i].first == cor.first){
                continue;
            }
            return x2[i];
        }
    }
    return x2[0];

}

