#include <stdio.h> #include <math.h> #define N 32 int main(void) { int T; scanf("%d",&T); int m,k; int x; while(T--){ scanf("%x%d%d",&x,&m,&k); printf("%08x\n",(x & ((1<<(32-m))-1)) + (k<<(32-m))); } return 0; }