题意:

sol:





#include <cstdio>
#include <bitset>
using namespace std;
bitset<30> a,b((1<<30) - 1),c;
int n,m;
int main(){
    scanf("%d%d",&n,&m);
    char op[10];int x;
    for(int i = 0;i < n;i++){
        scanf("%s%d",op,&x);
        if(op[0] == 'A') a &= x,b &= x;
        else if(op[0] == 'O') a |= x,b |= x;
        else a ^= x,b ^= x;
    }
    for(int i = 0;i < 30;i++){
        if(a[i]) c[i] = 1;
        else if(b[i]){
            c[i] = 1;
            if(c.to_ulong() > m) c[i] = 0;
        }
    }
    printf("%d\n",c.to_ulong());
    return 0;
}