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

c = []

for _ in range(h):

    s = eval(input())

    c.append(s)

    c.append(s)

print(("\n".join(c)))
h, w = list(map(int, input().split()))

c = []

for i in range(h):

    s = eval(input())

    c.append(s)

    c.append(s)

print(("\n".join(c)))

h, w = list(map(int, input().split()))
c = []
for _ in range(h):
    s = eval(input())
    c.append(s)
    c.append(s)
print(("\n".join(c)))

h, w = list(map(int, input().split()))
c = []
for i in range(h):
    s = eval(input())
    c.append(s)
    c.append(s)
print(("\n".join(c)))

-for _ in range(h): +for i in range(h):