#include <bits/stdc++.h>
#include "vision.h"
using namespace std;

vector<int> getVisionPattern1d(){
    return {1, 2, 3, 1};
}

int getMove1d(vector<int> v){
    int x = v.size() / 2;
    if(x == 1){
        if(v[0] == 3 || v[2] == 3){
            if(v[0] == 1) return 0;
            return 2;
        }
        if(v[0] == 2) return 0;
        return 2;
    }
    if(x == 2){
        for(int i = 0; i < 5; i++){
            if(v[i] == 3) return i;
        }
    }
    if(v[0] == 2) return 0;
    return 6;
}

vector<vector<int>> getVisionPattern2d(){
    return {{1, 2, 3}, {2, 3, 1}, {3, 1, 2}};
}

pair<int, int> getMove2d(vector<vector<int>> v){
    int n = v.size();
    int x = v[n / 2][n / 2];
    if(x == 1){
        //am 3 in coltul dreapta jos
        if(v[0][0] == 3)  return {0, 0};
        if(v[0][2] == 3)  return {0, 2};
        if(v[2][0] == 3)  return {2, 0};
        return {2, 2};
    }
    if(x == 2){
        //exact la fel
        if(v[0][0] == 3)  return {0, 0};
        if(v[0][4] == 3)  return {0, 4};
        if(v[4][0] == 3)  return {4, 0};
        return {4, 4};
    }
    //aici nu am in coltul mare, dar pe patrat 3x3 am un singur 2 in colt
    if(v[2][2] == 2)  return {2, 2};
    if(v[2][4] == 2)  return {2, 4};
    if(v[4][4] == 2)  return {4, 4};
    return {4, 2};
}

