#include <bits/stdc++.h>

std::vector<int> getVisionPattern1d() {
  std::vector<int> ret = {1, 1, 2, 1, 3};
  return ret;
}

int getMove1d(std::vector<int> v) {
  if(v.size() == 3) {
    if(v[0] == 3)
      return 0;
    if(v[2] == 3)
      return 2;
    if(v[0] == 2)
      return 0;
    return 2;
  }else if(v.size() == 5) {
    if(v[0] == 3)
      return 0;
    return 4;
  } else {
    if(v[0] == 2)
      return 0;
    return 6;
  }
}
std::vector<std::vector<int>> getVisionPattern2d() {
  std::vector<std::vector<int>> ret(3);
  ret[0].resize(3);
  ret[1].resize(3);
  ret[2].resize(3);
  ret = {{1, 2, 1},
         {3, 4, 1},
         {1, 1, 1}};
  return ret;
}
std::pair<int, int> getMove2d(std::vector<std::vector<int>> v){
  int n = v.size();
  if(n == 3) {
    for( int i = 0; i < n; i++ ) {
      for( int j = 0; j < n; j++ ) {
        if(v[i][j] == 4)
          return {i, j};
      }
    }
  }
  if(n == 5 || n == 7) {
    int mij = n / 2;
    if(v[mij][mij - 1] == 4)
      return {mij, mij - 1};
    if(v[mij][mij + 1] == 4)
      return {mij, mij + 1};
    if(v[mij - 1][mij] == 4)
      return {mij - 1, mij};
    if(v[mij][mij + 1] == 4)
      return {mij, mij + 1};
  }
  // sunt pe 4
  int mij = n / 2;
  if(v[mij][mij - 1] == 3 && v[mij - 1][mij] == 2) {
    return {n - 1, n - 1};
  }
  if(v[mij][mij - 1] == 3 && v[mij - 1][mij] != 2)
    return {0, n - 1};
  if(v[mij][mij - 1] != 3 && v[mij - 1][mij] == 2)
    return {n - 1, 0};
  return {0, 0};
}
