int now, ans; intmain(){ ma['A'] = 1; ma['O'] = 2; ma['X'] = 3; scanf("%d%d", &n, &m); for (int i = 1; i <= n; ++i) { char c[5]; scanf("%s%d", c, &Q[i].v); Q[i].opt = ma[c[0]]; } for (int k = 30; ~k; --k) { int s = 0; for (int i = 1; i <= n; ++i) { int opt = Q[i].opt, v = Q[i].v >> k & 1; switch (opt) { case1 : s &= v; break; case2 : s |= v; break; case3 : s ^= v; break; } } if (s) { ans += 1 << k; continue; } s = 1; for (int i = 1; i <= n; ++i) { int opt = Q[i].opt, v = Q[i].v >> k & 1; switch (opt) { case1 : s &= v; break; case2 : s |= v; break; case3 : s ^= v; break; } } if (!s || now + (1 << k) > m) continue; now += 1 << k; ans += 1 << k; } cout << ans << endl; return0; }