<reponame>trustedmercury/ccc-solutions<filename>2016/j2.py<gh_stars>1-10
# 15/15

square = tuple(tuple(map(int, input().split())) for _ in range(4))

total = sum(square[0])

for index in range(4):
    if sum(square[index]) != total:
        print("not magic")
        exit()

    if sum(tuple(x[index] for x in square)) != total:
        print("not magic")
        exit()

print("magic")

# 15/15

square = tuple(tuple(map(int, input().split())) for _ in range(4))

total = sum(square[0])

for index in range(4):
    if sum(square[index]) != total:
        print("not magic")
        exit()

    if sum(tuple(x[index] for x in square)) != total:
        print("not magic")
        exit()

print("magic")