#include using namespace std; const int MaxN = (int)4e5 + 10; const int MOD = (int)1e9 + 7; const int INF = 1e9; const int K = 9; int n, m, k; int a[MaxN], T[MaxN], X[MaxN]; int cnt[1 << 18], foo[1 << 18]; long long readInt(long long l,long long r,char endd){ long long x=0; int cnt=0; int fi=-1; bool is_neg=false; while(true){ char g=getchar(); if(g=='-'){ assert(fi==-1); is_neg=true; continue; } if('0'<=g && g<='9'){ x*=10; x+=g-'0'; if(cnt==0){ fi=g-'0'; } cnt++; assert(fi!=0 || cnt==1); assert(fi!=0 || is_neg==false); assert(!(cnt>19 || ( cnt==19 && fi>1) )); } else if(g==endd){ if(is_neg){ x= -x; } assert(l<=x && x<=r); return x; } else { assert(false); } } } string readString(int l,int r,char endd){ string ret=""; int cnt=0; while(true){ char g=getchar(); assert(g!=-1); if(g==endd){ break; } cnt++; ret+=g; } assert(l<=cnt && cnt<=r); return ret; } long long readIntSp(long long l,long long r){ return readInt(l,r,' '); } long long readIntLn(long long l,long long r){ return readInt(l,r,'\n'); } string readStringLn(int l,int r){ return readString(l,r,'\n'); } string readStringSp(int l,int r){ return readString(l,r,' '); } void SOS() { memcpy(foo, cnt, sizeof(foo)); for (int bit = 0; bit < k; ++bit) { for (int mask = 0; mask < 1 << k; ++mask) { if (~mask & (1 << bit)) { foo[mask] += foo[mask ^ (1 << bit)]; } } } } int main() { // freopen("input.txt", "r", stdin); // scanf("%d%d%d", &n, &m, &k); n = readIntSp(1, 7.5e4); m = readIntSp(1, 7.5e4); k = readIntLn(1, 18); for (int i = 1; i <= n; ++i) { // scanf("%d", &a[i]); if (i < n) { a[i] = readIntSp(0, (1 << k) - 1); } else { a[i] = readIntLn(0, (1 << k) - 1); } ++cnt[a[i]]; } SOS(); for (int i = 1; i <= m; ++i) { int t, x; // scanf("%d%d", &t, &x); t = readIntSp(1, 3); x = readIntLn(0, (1 << k) - 1); T[i] = t; X[i] = x; if (t == 1) { cnt[x] += 1; } else if (t == 2) { if (cnt[x] == 0) throw; cnt[x] -= 1; } if ((i & ((1 << K) - 1)) == 0) { SOS(); //help the program } if (t == 3) { int ans = 0; for (int bit = k - 1; bit >= 0; --bit) { int taked = ans | (1 << bit); int cur = foo[taked]; for (int j = i; (j & ((1 << K) - 1)) != 0; --j) { if (T[j] == 1) { if ((X[j] & taked) == taked) { ++cur; } } if (T[j] == 2) { if ((X[j] & taked) == taked) { --cur; } } } if (cur >= x) { ans |= 1 << bit; } } printf("%d\n", ans); } } assert (getchar() == EOF); return 0; }