This non-discriminatory year-end holiday season you have received a present. It has to stay neatly wrapped for some time, but you want to know what it is now. Estimating the weight of the package and the weights of possible presents, pick the closest match.
The input file DATA1.txt will contain 5 test cases, each 5 lines long. The first line will be an integer value, the weight of the package. The following 4 lines will be possible choices, each in form: name weight, where name is a single word and weight is an integer weight for this choice.
The output file OUT1.txt will contain 5 lines of output, each being the name of the closest guess out of the choices. If two items tie, then answer with the heavier of the two.
-2 helium -3 air 0 socks 1 brick 10 4 brick 10 books 7 socks 1 air 0