import base64
for _ in range(0,int(input())):
    s=str(input())
    x=base64.b32decode(s)
    y=base64.b64encode(x)
    print(y.decode("utf-8"))