#include <bits/stdc++.h>
#include "minerals.h"
using namespace std;
bool query(int x) {
static int last = 0;
int cur = Query(x);
bool ans = cur != last;
last = cur;
return ans;
}
void solve(vector<int> l, vector<int> r, bool fill) {
int n = (int) l.size(), m = ceil(n * 0.36);
if (fill) {
m = n - m;
}
if (n == 1) {
Answer(l[0], r[0]);
return;
}
if (fill) {
for (int i = n - 1; i >= m; --i) {
query(l[i]);
}
} else {
for (int i = 0; i < m; ++i) {
query(l[i]);
}
}
vector<int> left, right;
random_shuffle(r.begin(), r.end());
for (auto i : r) {
if ((int) left.size() == m) {
right.push_back(i);
} else if ((int) right.size() == n - m) {
left.push_back(i);
} else if (query(i)) {
right.push_back(i);
} else {
left.push_back(i);
}
}
solve(vector<int>(l.begin(), l.begin() + m), left, true);
solve(vector<int>(l.begin() + m, l.end()), right, false);
}
void Solve(int n) {
vector<int> l, r;
for (int i = 1; i <= n * 2; ++i) {
if (query(i) == 1) {
l.push_back(i);
} else {
r.push_back(i);
}
}
solve(l, r, true);
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNpbmNsdWRlICJtaW5lcmFscy5oIgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmJvb2wgcXVlcnkoaW50IHgpIHsKICBzdGF0aWMgaW50IGxhc3QgPSAwOwogIGludCBjdXIgPSBRdWVyeSh4KTsKICBib29sIGFucyA9IGN1ciAhPSBsYXN0OwogIGxhc3QgPSBjdXI7CiAgcmV0dXJuIGFuczsKfQoKdm9pZCBzb2x2ZSh2ZWN0b3I8aW50PiBsLCB2ZWN0b3I8aW50PiByLCBib29sIGZpbGwpIHsKICBpbnQgbiA9IChpbnQpIGwuc2l6ZSgpLCBtID0gY2VpbChuICogMC4zNik7CiAgaWYgKGZpbGwpIHsKICAgIG0gPSBuIC0gbTsKICB9CiAgaWYgKG4gPT0gMSkgewogICAgQW5zd2VyKGxbMF0sIHJbMF0pOwogICAgcmV0dXJuOwogIH0KICBpZiAoZmlsbCkgewogICAgZm9yI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