#include<bits/stdc++.h> #define mp make_pair #define pb push_back using namespace std; typedef long long LL; typedef pair<int,int> PII; inline LL read() { LL x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();} return x*f; } const int N=100008; int n,m,maxi,ans; char s[5]; struct node{ int type,x; inline int calc(const int &y){ if(type==0){ return x|y; } else if(type==1){ return x&y; } else{ return x^y; } } }a[N]; inline int solve(int x) { for(int i=1;i<=n;++i){ x=a[i].calc(x); } return x; } int main() { n=read();m=read(); for(int i=1;i<=n;++i){ scanf("%s",s); if(s[0]=='O'){ a[i].type=0; } else if(s[0]=='A'){ a[i].type=1; } else{ a[i].type=2; } a[i].x=read(); } for(maxi=1;maxi<=m;maxi<<=1); for(maxi>>=1;maxi;maxi>>=1){ if(solve(0)&maxi){ continue; } if((ans^maxi)<=m&&(solve(maxi)&maxi)){ ans^=maxi; } } printf("%d",solve(ans)); return 0; }
|
近期评论