h,w = map(int,input().split())

rlists = []

for i in range(h):

    yoko = list(input())

    rlists.append(yoko)

    rlists.append(yoko)

for rlist in rlists:

    print(*rlist,sep="")

h,w = list(map(int,input().split()))

for i in range(h):

    line = eval(input())

    print(line)

    print(line)

h, w = map(int, input().split())
rlists = []
for i in range(h):
    yoko = list(input())
    rlists.append(yoko)
    rlists.append(yoko)
for rlist in rlists:
    print(*rlist, sep="")

h, w = list(map(int, input().split()))
for i in range(h):
    line = eval(input())
    print(line)
    print(line)

-h, w = map(int, input().split()) -rlists = [] +h, w = list(map(int, input().split())) -    yoko = list(input()) -    rlists.append(yoko) -    rlists.append(yoko) -for rlist in rlists: -    print(*rlist, sep="") +    line = eval(input()) +    print(line) +    print(line)