import base64 t=input() while(t!=0): x=raw_input() b32=x ans=base64.b32decode(b32) ans=base64.b64encode(ans) print ans t=t-1