Олимпиадный тренинг

Задача 44310. T-shirts and socks


Задача

Темы:
As you know, in autumn and winter it dawns late and so you want to sleep at least a little more in the morning, and not go to school! Some schoolchildren are even ready to dress without opening their eyes, just to postpone the moment of awakening. So Sasha decided that he could easily pull out a T-shirt and socks from the closet by touch with his eyes closed, and only then turn on the light and get dressed.
Sasha has two drawers in his closet. One of them contains A blue and B red T-shirts, the other contains — C blue and D red pairs of socks. Sasha wants the shirt and socks to be the same color. He blindly draws out M T-shirts and N pairs of socks. On the very first morning, Sasha wondered what the minimum total number of items of clothing (M + N) he should pull out so that they would be guaranteed to include a T-shirt and socks of the same color. What color the clothes will be, it doesn't matter for Sasha.

Input
The program receives four non-negative integers A, B, C, D, written in separate lines: A — number of blue jerseys, B — number of red jerseys, C — quantity blue socks, D — number of red socks. All numbers do not exceed 109 . It is guaranteed that there is a one-color set of a T-shirt and socks in the wardrobe.

Imprint
The program should output two numbers: the number of T-shirts M and the number of pairs of socks N that Sasha should take. It is necessary that among M T-shirts and N pairs of socks there must be a one-color pair, while the sum M + N must be minimal.
 
Examples
# Input Output
1 6
2
7
3
3 4

Remark
In the example from the condition, the closet contains A = 6 blue T-shirts and B = 2 red T-shirts. If you take 3 T-shirts, then among them there will definitely be a blue one. The other box contains C = 7 pairs of blue socks and D = 3 pairs of red socks. If you take 4 pairs, then among them there will definitely be a pair of blue
socks. Therefore, if you blindly take 3 T-shirts and 4 pairs of socks, then among them there will definitely be a one-color (blue) set of a T-shirt and socks.