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