408105: GYM102986 A Favorite Foods
Description
Francesca is compiling a list of her favorite (and least favorite) foods to help with meal planning. She gives an integer rating for each of $$$n$$$ different foods, where a higher rating indicates that Francesca likes the food more. Obviously, Francesca would prefer to prepare foods with a high rating more often and prepare foods with a low rating less often.
Given the list of foods and ratings Francesca has given for each food, figure out Francesca's least favorite food (food with the lowest rating) and her favorite food (food with the highest rating). It is guaranteed that each food rating will be distinct and the same food will not appear multiple times on Francesca's list.
InputThe first line of the input consists of a single integer $$$n$$$ $$$(1 \leq n \leq 50)$$$, giving the number of foods that Francesca has given a rating for. The next $$$n$$$ lines each consist of a single token food name $$$f_i$$$ $$$(1 \leq |f_i| \leq 30)$$$ and a rating $$$r_i$$$ associated with that food $$$(-10^9 \leq r_i \leq 10^9)$$$. $$$f_i$$$ will always consist of only uppercase and lowercase letters.
OutputOutput Francesca's least favorite food and favorite food, separated by a space.
ExampleInput3 Sandwiches 23 Sardines -2 Pizza 23984Output
Sardines Pizza