#include "interactive.h"
#include <bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define fi first
#define se second
#define FOR(i, a, b) for (int i = a, _b = b; i <= _b; ++i)
#define FORD(i, a, b) for (int i = a, _b = b; i >= _b; --i)
#define FORLL(i, a, b) for (ll i = a, _b = b; i <= _b; ++i)
#define FORDLL(i, a, b) for (ll i = a, _b = b; i >= _b; --i)
#define all(x) x.begin(), x.end()
#define uni(x) sort(all(x)), x.erase(unique(all(x)), x.end())
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define dbg(...) debug(#__VA_ARGS__, __VA_ARGS__)
template<typename T>
void __prine_one(const char *&s, const T &x)
{
while (*s == ' ') ++s;
const char *p = s;
int bal = 0;
while (*s)
{
if (*s == '(') ++bal;
else if (*s == ')') --bal;
else if (*s == ',' && bal == 0) break;
++s;
}
cerr.write(p, s - p) << " = " << x;
if (*s == ',')
{
cerr << " , ";
++s;
}
}
template<typename... Args>
void debug(const char *s, Args... args)
{
cerr << "[ ";
int dummy[] = {0, (__prine_one(s, args), 0)...};
(void)dummy;
cerr << " ]\n\n";
}
template<class X>
bool maximize(X &a, const X &b)
{
if (b > a)
{
a = b;
return true;
}
return false;
}
template<class X>
bool minimize(X &a, const X &b)
{
if (b < a)
{
a = b;
return true;
}
return false;
}
// --------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
multiset<int> toSet(vector<int> vec)
{
multiset<int> ms;
for (int x : vec)
ms.insert(x);
return ms;
}
vector<int> guess(int n)
{
// cong 1 vao khi goi ask hoac get_pairwise_xor
vector<int> a(n, 0);
vector<vector<int>> vecAsk(7);
map<int, int> mp;
FOR(mask, 1, n - 1)
{
FOR(i, 0, 6)
{
if (mask >> i & 1)
vecAsk[i].push_back(mask + 1);
}
}
a[0] = ask(1);
FOR(bit, 0, 6)
{
if (vecAsk[bit].empty()) continue;
multiset<int> B = toSet(get_pairwise_xor(vecAsk[bit]));
vecAsk[bit].push_back(1);
multiset<int> A = toSet(get_pairwise_xor(vecAsk[bit]));
for (int x : B)
A.erase(A.find(x));
A.erase(A.find(0));
for (int x : A)
{
mp[x ^ a[0]] |= 1 << bit;
}
}
for (const auto &p : mp)
{
a[p.se] = p.fi;
}
return a;
}