i=b=0 while 1: for s in raw_input().split(): if i:b=len(p)-len(s);s=s[::-1] p=b*' '+s;print p;i^=1