R, K = map(int, input().split()) H, W = map(int, input().split()) a = [tuple(input()) for _ in [0]*H] ans = [[0]*(H*K) for _ in [0]*(W*K)] for _y in range(H*K): y = _y//K for _x in range(W*K): x = _x//K ans[_x][_y] = a[y][x] for i in range(W*K): print("".join(ans[i]))