Kings of Persia | 프로그래밍의 벗 PivotOJ
PivotOJ

Kings of Persia

시간 제한: 2000ms메모리 제한: 256MB출처: ICPC Asia Tehran Regional Contest 2014BOJ 10599

문제

Mahya loves to know more about the history of her country. She is in particular interested in the history of the ancient kings of Persia. Recently, Mahya got curious to know how long each of her favorite kings had lived. So, she started searching the web, and collecting information about the kings lives.

Unfortunately, in most cases, the exact dates on which the kings were born or died are not available in resources. So, Mahya could only find some ranges for possible dates of birth and death for each of the kings. For example, for Cyrus the Great, she could only find that the date of birth was between 600 BC and 575 BC, and the date of death was 530 BC. So, she concluded that Cyrus the Great had lived at least 45 years and at most 70 years.

Mahya has created a long list of her favorite kings, and for each king, has written down two ranges showing the birth range and the death range of that king. Since the list is a bit lengthy, she needs your help to process the list, and produce for each king the minimum and the maximum age. Note that if a king was born in year x and died in year y, then he lived y − x years.

입력

There are multiple test cases in the input. Each test case consists of a line containing four integers a, b, c, d, where −5000 ⩽ a ⩽ b < c ⩽ d ⩽ 2000. The range [a, b] shows the birth range, and [c, d] shows the death range. The input terminates with 0 0 0 0 which should not be processed.

출력

For each test case, output a line containing the minimum and the maximum age as two integers separated by a space.

예제

예제 1

입력
100 110 180 185
-600 -575 -530 -530
-25 10 72 86
0 0 0 0
출력
70 85
45 70
62 111
코드를 제출하려면 로그인하세요.