/* Solution Author: Alexander Logunov Date: 29.04.2018 */ #include using namespace std; #define FILE "a" #ifdef LOCAL #define eprintf(args...) fprintf(stderr, args), fflush(stdout) #else #define eprintf(args...) ; #endif using uint = unsigned int; int n; bool read() { if (!(cin >> n)) { return 0; } return 1; } uint getBit(uint mask, int pos) { return (mask >> pos) & 1; } void solve() { static const int LENGTH = 32; unordered_set blocked[LENGTH + 1]; for (int i = 0; i < n; i++) { string q, s; cin >> q; uint p[4]; scanf("%u.%u.%u.%u", &p[0], &p[1], &p[2], &p[3]); uint ip = 0; for (int j = 0; j < 4; j++) { ip = ip * 256 + p[j]; } if (q == "b") { int len; scanf("/%d", &len); uint cur_ip = 0; for (int pos = 0; pos < len; pos++) { cur_ip ^= getBit(ip, LENGTH - 1 - pos) << (LENGTH - 1 - pos); } blocked[len].insert(cur_ip); } else if (q == "?") { bool answer = false; uint cur_ip = 0; for (int pos = 0; pos < LENGTH; pos++) { cur_ip ^= getBit(ip, LENGTH - 1 - pos) << (LENGTH - 1 - pos); answer |= blocked[pos + 1].count(cur_ip) > 0; } cout << (answer ? "Yes" : "No") << '\n'; } } } int main() { #ifdef LOCAL freopen(FILE ".in", "r", stdin); freopen(FILE ".out", "w", stdout); #endif while (read()) { solve(); } #ifdef LOCAL eprintf("Time %.5f\n", clock() * 1.0 / CLOCKS_PER_SEC); #endif }