a = int(eval(input()))

b = int(eval(input()))

c = int(eval(input()))

d = int(eval(input()))



print(((a if a <= b else b) + (c if c <= d else d)))
a = int(eval(input()))

b = int(eval(input()))

c = int(eval(input()))

d = int(eval(input()))

ans = min(a, b) + min(c, d)

print(ans)
a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
d = int(eval(input()))
print(((a if a <= b else b) + (c if c <= d else d)))

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

-print(((a if a <= b else b) + (c if c <= d else d))) +ans = min(a, b) + min(c, d) +print(ans)