#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> ad[20005];
int dis[20005];
vector<int> Mark(int n, int m, int A, int B, vector<int> U, vector<int> V) {
//Solve for the case A = 3, B = 0;
for(int i = 0; i < m; i++){
ad[U[i]].push_back(V[i]);
ad[V[i]].push_back(U[i]);
}
memset(dis, 0x3f, sizeof(dis));
queue<int> w; dis[0] = 0; w.push(0);
while(w.size() > 0){
int u = w.front(); w.pop();
for(int v : ad[u]) if(dis[v] > dis[u] + 1){
dis[v] = dis[u] + 1;
w.push(v);
}
}
vector<int> ans(m);
for(int i = 0; i < m; i++){
int u = U[i], v = V[i];
ans[i] = min(dis[u], dis[v])%3;
}
return ans;
}
#include "Catherine.h"
#include<bits/stdc++.h>
using namespace std;
int A, B;
void Init(int a, int b) {
A = a; B = b;
}
int Move(vector<int> f) {
int c = 0;
for(int i : f) if(i > 0) c++;
if(c == 1){
for(int i = 0; i < 3; i++) if(f[i] > 0){
return i;
}
return -1; //Never happen
}
else{
//c = 2
if(f[0] * f[1] > 0) return 0;
else if(f[1] * f[2] > 0) return 1;
else return 2;
}
}