#include<stdio.h> int main(void){ int t; scanf("%d",&t); while(t--){ unsigned int a,m,k,o; scanf("%x%d%d",&a,&m,&k); k<<=32-m; o=(1<<(32-m))-1; //printf("%x\n",(1<<(32-m))-1); a=a&o; printf("%08x\n",a+k); } }