A=[int(eval(input())) for i in range(4)]

print((min(A[0]+A[2],A[0]+A[3],A[1]+A[2],A[1]+A[3])))
a,b,c,d=[int(eval(input())) for i in range(4)]

print((min(a,b)+min(c,d)))
A = [int(eval(input())) for i in range(4)]
print((min(A[0] + A[2], A[0] + A[3], A[1] + A[2], A[1] + A[3])))

a, b, c, d = [int(eval(input())) for i in range(4)]
print((min(a, b) + min(c, d)))

-A = [int(eval(input())) for i in range(4)] -print((min(A[0] + A[2], A[0] + A[3], A[1] + A[2], A[1] + A[3]))) +a, b, c, d = [int(eval(input())) for i in range(4)] +print((min(a, b) + min(c, d)))