#include #include #include #include #include #include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); uint32_t Q, i; uint8_t j; cin >> Q; vector> query(Q); for (i = 0; i != Q; ++i) { cin >> query[i].first; if (query[i].first != '3') cin >> query[i].second; } unordered_set S; array bitwise_counter; uint32_t ans; bitwise_counter.fill(UINT32_C(0)); for (i = 0; i != Q; ++i) switch (query[i].first) { case '1': if (S.find(query[i].second) == S.end()) { S.insert(query[i].second); for (j = 0; j != bitwise_counter.size(); ++j) if ((query[i].second >> j) & UINT32_C(1)) ++bitwise_counter[j]; } break; case '2': if (S.find(query[i].second) != S.end()) { S.erase(query[i].second); for (j = 0; j != bitwise_counter.size(); ++j) if ((query[i].second >> j) & UINT32_C(1)) --bitwise_counter[j]; } break; case '3': if (S.empty()) cout << "-1\n"; else { ans = 0; for (j = 0; j != bitwise_counter.size(); ++j) if (bitwise_counter[j] == S.size()) ans |= UINT32_C(1) << j; cout << ans << '\n'; } } return 0; }