You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket.  Find the minimum total fare when the optimal choices are made for trains and buses.
v1=int(input())
v2=int(input())
v3=int(input())
v4=int(input())

print(max(v1,v2)+max(v3,v4))
v1=int(input())
v2=int(input())
v3=int(input())
v4=int(input())

print(min(v1,v2)+min(v3,v4))
