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

for i in range(h):

    c = eval(input())

    print(c)

    print(c)

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

a = [tuple(eval(input())) for _ in range(h)]

for i in a:

    print(("".join(i)))

    print(("".join(i)))

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

h, w = list(map(int, input().split()))
a = [tuple(eval(input())) for _ in range(h)]
for i in a:
    print(("".join(i)))
    print(("".join(i)))

-for i in range(h): -    c = eval(input()) -    print(c) -    print(c) +a = [tuple(eval(input())) for _ in range(h)] +for i in a: +    print(("".join(i))) +    print(("".join(i)))