#include<iostream> #include<cstring> #define x first #define y second using PSI = std::pair<std::string, int>;
constint N = 1e5 + 10;
int n, m, t, ans; std::string op; PSI ops[N];
template <classT> T calc(const T& a, const std::string& op, const T& b){ if(op == "AND") return a & b; elseif(op == "OR") return a | b; elseif(op == "XOR") return a ^ b; std::cout << "Error\n"; return-1; }
intbreakThrough(int a, int idx){ for(int i = 0; i < n; ++i) { std::string op = ops[i].x; int b = ops[i].y >> idx & 1; a = calc<int>(a, op, b); } return a; }
intmain(){ std::cin >> n >> m;
for(int i = 0; i < n; ++i) { std::cin >> op >> t; ops[i] = {op, t}; }
bool less = 0; for(int i = 30; i >= 0; --i) { int input = m >> i & 1; bool isZero = !input; int output1 = breakThrough(input, i); int output2 = breakThrough(!input, i); // 有 16 种组合 if(isZero) { if(less) { if(output1) { if(output2) { // [1] 前缀已小于m,低位可自由选择,实际输入为 0 情况下输出为 1,输入为 1 的情况下输出为 1 ans += 1 << i; } else { // [2] 前缀已小于m,低位可自由选择,实际输入为 0 情况下输出为 1,输入为 1 的情况下输出为 0 ans += 1 << i; } } else { if(output2) { // [3] 前缀已小于m,低位可自由选择,实际输入为 0 情况下输出为 0,如果输入为 1 情况下输出 1 ans += 1 << i; } else { // [4] 前缀已小于m,低位可自由选择,实际输入为 0 情况下输出为 0,如果输入为 1 情况下输出 0