Hogwarts is welcoming the new term! After Voldemort and the Death Eater were wiped out by Harry Potter and his friends, Harry becomes the glory of the Wizarding World, magician treat him as model, hero, king… and much more than that. So on the ceremony held to signal the beginning of a new school semester, they decide to invite Harry Potter and his three friends: Ginny, Ron and Hermione.
Back to their Alma Mater, Harry and his three friends find a store to purchase some present. They can use at most M units of money, what’s more, they don’t have enough energy to take the presents to Hogwarts if their total weight is exceeding W or the total number is exceeding S. In the store, there are N kinds of present, each of them has price Pi, weight Wi, and value Vi, and as it’s a magical world, any present’s amount is infinite and can be purchased for many times.
Unfortunately, all of them have different idea to buy the gifts. Ginny wants the total number to be the largest, while Ron thinks the more money they cost, the more sincerity there will be shown, Harry wonders the biggest weight they can take because he always likes to challenge himself, Hermione, of course, is already beginning to calculating the biggest value.
Here you see, your task is very simple, calculating the four numbers.