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