#include <iostream>
using namespace std;
int main() {
int T;
cin >> T;
long long tem = (1ll << 12) - 1;
while (T--) {
int o, x, p;
cin >> o >> x >> p;
if (o == 1) {
cout << (x << p & tem) << endl;
} else if(o == 2){
x >>= p;
for(int i = 1;i <= p;++i){
x += (1 << (12 - i));
}
cout<<x<<endl;
} else if(o == 3){
if(x & (1 << (p))) x -= (1 << (p));
cout<<x<<endl;
} else if(o == 4){
cout<<(x | (1 << p))<<endl;
}
}
}
// 64 位输出请用 printf("%lld")

京公网安备 11010502036488号