n, m = map(int, input().split()) li = [] for i in range(n): raw = input()[:m] li.append(raw) for i in li[::-1]: print(i[::-1])