#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
int direction(int i, int j, int r, int c) {
int ans=0;
//0 = east, 1=west, 2 = south, 3=north
if (r<i) ans = 3;
if (i<r) ans = 2;
if (j>c) ans = 1;
if (j<c) ans = 0;
return ans;
}
bool flag = false;
int f(vector<int> &num) {
int ans=0;
int pw = 1;
for (auto x : num) {
ans += x*(pw);
pw *= 3;
}
return ans;
}
int g(int i1, int j1, int i2, int j2) {
return abs(i1-i2) + abs(j1-j2);
}
void Anna(int n, int K, std::vector<int> R, std::vector<int> C) {
for (int i=0; i<n; i++) {
for (int j=0; j<n; j++) {
vector<int> vals;
for (int c=0; c<K; c++) {
int dis = g(i, j, R[c], C[c]);
vals.push_back(dis%3);
}
int num = f(vals);
if (num==0) {
vals.push_back(1);
}
SetFlag(i, j, f(vals));
}
}
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int t(int x) {
return (x&(1)) + (x&(2));
}
std::vector<int> Bruno(int K, std::vector<int> value) {
vector<int> ans;
for (int i=0; i<K; i++) {
int num = value[4]%3;
int mn = (num-1+3)%3;
int l = value[3]%3, r = value[5]%3, u = value[1]%3, d = value[7]%3;
if (l==mn) {
ans.push_back(1);
}
else if (r == mn) {
ans.push_back(0);
}
else if (u == mn) {
ans.push_back(3);
}
else if (d == mn) {
ans.push_back(2);
}
else {
ans.push_back(4);
}
for (int c=0; c<9; c++) {
value[c] /= 3;
}
}
return ans;
}