#include using namespace std; typedef pair pii; typedef long long ll; typedef vector vi; #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define rep(i,n) rep2(i,0,n) #define rep2(i,m,n) for(int i=m;i<(n);i++) #define ALL(c) (c).begin(),(c).end() #define dump(x) cout << #x << " = " << (x) << endl constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); } template ostream& operator<<(ostream& os, const pair& p) { os<<"("< ostream& operator<<(ostream& os, const vector& v) { os<<"{"; rep(i, v.size()) { if (i) os<<","; os<= 2) { vi nx; for (int i = 0; i < (int)vec.size() / 2; ++i) { int x = vec[i * 2]; int y = vec[i * 2 + 1]; bool f = ask(x, y); if (f) { w[x][y] = 1; w[y][x] = 0; nx.pb(x); } else { w[y][x] = 1; w[x][y] = 0; nx.pb(y); } } if (vec.size() & 1) { nx.pb(vec.back()); } vec.swap(nx); } return vec[0]; } int main() { int N; cin >> N; memset(w, -1, sizeof(w)); vi vec; rep(i, N) vec.pb(i); int p = rem(vec); vi cand; rep(i, N) if (w[p][i] == 1) { cand.pb(i); } int q = rem(cand); answer(q); return 0; }