#include "bits/stdc++.h"
#include "vision.h"
// #include "grader.cpp"

using namespace std;

#define SZ(s) (int)s.size()

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

int getMove1d(vector<int> v) {
    int n = SZ(v);
    if(v[n / 2] == 1) {
        for(int i = 0; i < n; i++) {
            if(v[i] != 1) return i;
        }
    }
    if(v[n / 2] == 2) {
        for(int i = 0; i < n; i++) {
            if(v[i] == 3) return i;
        }
    }
    if(v[0] == 2) return 0;
    return n-1;
}

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

pair<int, int> getMove2d(vector<vector<int>> v) {
    int n = SZ(v), m = SZ(v[0]);
    if(v[n / 2][m / 2] == 1) {
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                if(v[i][j] != 1) return {i, j};
            }
        }
    }
    if(v[n / 2][m / 2] == 2) {
        for(int j = 0; j < m; j++) {
            if(v[n / 2][j] == 3) return {n / 2, j};
        }
    }
    if(v[n / 2][m / 2] == 3) {
        // assert(0);
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                if(v[i][j] == 2 and abs((n / 2) - i) == 3 and j == m / 2) return {i, j};
                if(v[i][j] == 2 and abs((n / 2) - i) == 2 and j != m / 2) return {i, j};
            }
        }
    }
}
