A grand book fair is taking place in your city, showcasing a dazzling array of books and publications. Safwan is a passionate book lover going to this book fair with a goal to buy as many books as possible.
There are unique books available at the fair, each with its own price and publication id. Also, there are publications participating in the fair, each offering a special discount on the total amount of the books you bought from them. Suppose you bought total books with prices from publication 1 and publication 1 is offering a discount amount of . Then you can buy these books for free. If the books price are , then you can buy these books spending amount.
Safwan will be asked queries. In each query, he will be given an amount. To maximize his reading pleasure, he will always try to purchase the maximum number of books with the given amount. Would you like to help him?
N. B. You can’t buy the same book multiple times.
The first line of the input contains three integers , , . Note that, is always less than or equal to and there is at least one book of every publication.
Each of the next lines consists of two integers and of -th book.
Next line contains an array of integers where means -th publisher will offer this discount if you buy one or more books from their collection.
Each of the next lines contains an integer which denotes the amount of that query.
For each query, print maximum number of books Safwan can buy with the given amount of that query. See the sample input output for more clarification.
5 2 3 5 1 5 1 6 1 7 2 12 2 6 0 23 35 50
4 5 5