#include "message.h"
#include<bits/stdc++.h>
#define fi first
#define se second
#define FOR(i, k, n) for(int i = k; i <= n; i++)
#define FOR1(i, k, n) for(int i = k; i >= n; i--)
#define pb push_back
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define ll long long
#define vll vector<ll>
#define pll pair<ll, ll>
#define re return 0
#define mii map<int, int>
#define input "wtf.inp"
#define output "wtf.out"
#define rf freopen(input, "r", stdin); freopen(output, "w", stdout)
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
const int base = 65537;
const int base1 = 31;
const int SZ = 320;
const ll INF = 1e18;
const long double EPS = 1e-9;
void add(int &a, int b)
{
a += b;
if(a >= mod) a -= mod;
if(a < 0) a += mod;
}
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
int randint(int l, int r)
{
return uniform_int_distribution<int>(l, r) (rd);
}
double rand(double l, double r)
{
return uniform_real_distribution<double>(l, r) (rd);
}
void send_message(vector<bool> M, vector<bool> C) {
vector<bool> send;
int a[20] = {0, 192831722, 94812843, 192402, 1829381, 1528374653, 81741, 1928467562, 19238123, 192312, 12391, 1458275938, 8192842, 91282321, 91828312, 918283762, 741829385, 8192834, 812, 3008};
FOR(i, 0, 19)
{
send.clear();
FOR(bit, 0, 30)
if((a[i] >> bit) & 1)
send.pb(1);
else
send.pb(0);
send_packet(send);
}
vi vt;
FOR(i, 0, 30)
if(C[i] == 0)
vt.pb(i);
int S = M.size();
send.clear();
FOR(i, 0, 30)
send.pb(0);
FOR(i, 0, 15)
if((S >> i) & 1)
{
send[vt[i]] = 1;
}
send_packet(send);
int res = S / 16;
send.clear();
FOR(j, 0, 30)
send.pb(0);
FOR(i, 0, res - 1)
{
int l = i * 16;
int r = l + 15;
FOR(j, 0, 30)
send[j] = 0;
FOR(j, l, r)
{
if(M[j] == 1)
send[vt[j - l]] = 1;
}
send_packet(send);
}
if(S % 16)
{
int l = res * 16;
int r = S - 1;
FOR(j, 0, 30)
send[j] = 0;
FOR(j, l, r)
if(M[j] == 1)
send[vt[j - l]] = 1;
send_packet(send);
}
return;
}
vector<bool> receive_message(vector<vector<bool>> R) {
bool vis[35];
int a[20] = {0, 192831722, 94812843, 192402, 1829381, 1528374653, 81741, 1928467562, 19238123, 192312, 12391, 1458275938, 8192842, 91282321, 91828312, 918283762, 741829385, 8192834, 812, 3008};
FOR(i, 0, 30)
vis[i] = 1;
FOR(i, 0, 19)
{
FOR(bit, 0, 30)
if((R[i][bit] != ((a[i] >> bit) & 1)))
vis[bit] = 0;
}
vi vt;
FOR(i, 0, 30)
if(vis[i])
vt.pb(i);
vector<bool> ans;
int S = 0;
FOR(i, 0, 15)
if(R[20][vt[i]] == 1)
S += (1 << i);
int res = S / 16;
if(S > 1024)
{
assert(0);
}
// FOR(i, 0, res - 1)
// {
// FOR(j, 0, 15)
// ans.pb(R[21 + i][vt[j]]);
// }
// int id = 21 + res;
// if(S % 16)
// {
// int l = res * 16;
// int r = S - 1;
// FOR(j, l, r)
// ans.pb(R[id][vt[j - l]]);
// }
return ans;
}