_=raw_input()
i=0
j=len(_)
while 1:print(i%j<1)*(_+_[0])[::(i<1)*2-1]or _[-i]+' '*~-j+_[i];i+=1
68b58eaedce7cec704b26c79d128b12998292a17
<mask token>

<mask token>
while 1:
    print(i % j < 1) * (_ + _[0])[::(i < 1) * 2 - 1] or _[-i] + ' ' * ~-j + _[i
        ]
    i += 1

_ = raw_input()
i = 0
j = len(_)
while 1:
    print(i % j < 1) * (_ + _[0])[::(i < 1) * 2 - 1] or _[-i] + ' ' * ~-j + _[i
        ]
    i += 1

_=raw_input()
i=0
j=len(_)
while 1:print(i%j<1)*(_+_[0])[::(i<1)*2-1]or _[-i]+' '*~-j+_[i];i+=1