## LCC/Moose '19 Contest 4 J1 - Growing Plants

View as PDF

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

You recently came into possession of plants. Each of these plants starts out with a height of , and will grow or decrease in height every day. You want to know, after days, which the tallest and shortest plants are.

#### Input Specification

The first line contains two integers, and , the number of plants you were given and the number of days you check them after.

The next lines will contain the name of the plant, and the amount the plant grows or decreases in height per day, separated by spaces. It is guaranteed that the name of the plant will be unique and will only contain lowercase alphabetical characters.

#### Output Specification

On the first line, output the name and height of the plant that is the tallest after days. On the second line, output the name and height of the plant that is the shortest after days. If multiple plants have the shortest or tallest height, output the one earliest in the input.

Note that for this question, the plant heights can go into the negatives.

#### Sample Input 1

3 5
bob -2
plant 5
steve 2

#### Sample Output 1

plant 30
bob -5

#### Sample Input 2

1 1
bob 50

#### Sample Output 2

bob 55
bob 55