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[j]for s in S[::-1]))