Extreme Temperatures

Interview

Time limit2sMemory limit512 MB

Summary
Read lines that pair a date with integer temperatures and print the smallest and largest values across every measurement.
Level

Easy1 of 10

Topics
Implementation, Array, String, Brute force
Solved
No attempts yet

Problem

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

Input

The input consists of N lines. Each line i (1 ≤ i ≤ N) is 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 token is an integer temperature measurement tij.

Output

Print a single line with two integers: the lowest and highest temperatures in the entire dataset, in this order.

Constraints

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

Examples1

  1. Example 1

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