N, K = map(int, input().split()) for _ in range(N): s = input() t = [] for c in s: t.extend([c] * K) for _ in range(K): print(''.join(t))