EasyRating 1000
Keyboard and Drive
Buy exactly one keyboard and one USB drive with at most b taka, spending as much as possible. Print the amount, or -1 if you can't buy both.
Input
b; then the keyboard prices; then the drive prices (each on one line).
Output
One integer.
Sample 1
Input
10 3 1 5 2 8
Output
9
Sample 2
Input
5 4 5
Output
-1
Output appears here