a, b, c, d = int(eval(input())), int(eval(input())), int(eval(input())), int(eval(input())),

print((min(a, b)+min(c, d)))
print((min(int(eval(input())), int(eval(input()))) + min(int(eval(input())), int(eval(input())))))
a, b, c, d = (
    int(eval(input())),
    int(eval(input())),
    int(eval(input())),
    int(eval(input())),
)
print((min(a, b) + min(c, d)))

print(
    (
        min(int(eval(input())), int(eval(input())))
        + min(int(eval(input())), int(eval(input())))
    )
)

-a, b, c, d = ( -    int(eval(input())), -    int(eval(input())), -    int(eval(input())), -    int(eval(input())), +print( +    ( +        min(int(eval(input())), int(eval(input()))) +        + min(int(eval(input())), int(eval(input()))) +    ) -print((min(a, b) + min(c, d)))