#include"communication.h"
#include <bits/stdc++.h>
using namespace std;
pair<int,int> decode(int n) {
mt19937 rng(n);
int x=rng();
if (x&1) {
for (int i=0; i<100; ++i) {
int f=receive(), s=receive();
if (f==s) {
if (f==0) return {1,2};
else return {2,3};
}
}
} else {
for (int i=0; i<100; ++i) {
int f=receive(), s=receive();
if (f==s) {
if (f==1) return {1,2};
else return {2,3};
}
}
}
x=rng();
if (x&1) return {1,3};
else return {2,3};
}
void encode(int n, int x) {
mt19937 rng(n);
int p=rng();
if (p&1) {
for (int i=0; i<100; ++i) {
if (x<=2) send(0);
else send(1);
if (x<=2) send(0);
else send(1);
}
} else {
for (int i=0; i<100; ++i) {
if (x>=2) send(0);
else send(1);
if (x>=2) send(0);
else send(1);
}
}
}