_={} x=0 d=y=5 for c in raw_input():_[y]=_.get(y,'').ljust(x)+c;d+=c<'!';x+=d%2;y+=5%(d%4+1)-1 for k in _:print _[k]