a,b=map(int,input().split()) z=[input() for i in range(a)] for s in z: for _ in range(b): print(''.join(x*b for x in s))