n, m = map(int, input().split()) a = [] for _ in range(n): s = input() s = s[::-1] a.append(s) a = a[::-1] for ss in a: print(ss)