R=range I=input H,W=map(int,I().split()) S=[I()for i in R(H)] for j in R(W):print(''.join(s[-1-j]for s in S))