시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB26514912154.260%

문제

Kristen is a meteorologist, who is monitoring extreme temperatures in the forest of Palaiseau. She has collected temperature measurements at various times over several days. Help her find out what the lowest and highest temperatures were in her entire dataset.

입력

The input is formed of N lines, each line i with 1 ≤ i ≤ N being a space-separated list of ki tokens:

  • the first token is the date of the measurement, in the form YYYY-MM-DD;
  • for 2 ≤ j ≤ ki, the j-th entry is an integer temperature measurement tij.

출력

The output should contain a single line with two integers: the lowest and highest temperatures in the entire dataset, in this order.

제한

  • 1 ≤ N ≤ 1 000;
  • 2 ≤ ki ≤ 100 for 1 ≤ i ≤ N;
  • −50 ≤ tij ≤ 50 for 1 ≤ i ≤ N and 2 ≤ j ≤ ki.

예제 입력 1

2020-01-15 5 4 6 8 12 13 12 9 7
2020-01-16 6 3 4 6 10 12 11 7

예제 출력 1

3 13