import typing import sys from collections import defaultdict input = lambda: sys.stdin.readline().strip() inf = 10**18 mod = 998244353 # import pypyjit # pypyjit.set_param('max_unroll_recursion=-1') # sys.setrecursionlimit(10**6) def solve(): N, K = map(int, input().split()) grid = [] for _ in range(N): grid.append(input()) for h in range(K*N): for w in range(K*N): print(grid[h//K][w//K], end='') print('') def main(): t = 1 for _ in range(t): solve() main()