f=lambda:min(int(eval(input())),int(eval(input())))

print((f()+f()))
A, B, C, D = [int(eval(input())) for _ in range(4)]

print((min(A, B)+min(C, D)))
f = lambda: min(int(eval(input())), int(eval(input())))
print((f() + f()))

A, B, C, D = [int(eval(input())) for _ in range(4)]
print((min(A, B) + min(C, D)))

-f = lambda: min(int(eval(input())), int(eval(input()))) -print((f() + f())) +A, B, C, D = [int(eval(input())) for _ in range(4)] +print((min(A, B) + min(C, D)))