Smoothie Stand

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Olivia runs a very famous and profitable smoothie stand. On any given day, she will always sell out (that is, she will sell as many smoothies as she has ingredients to make), regardless of what smoothie recipe she offers. Therefore, to simplify things, she has decided she will only make one type of smoothie per day. Now she has come to you to help her decide which of her recipes she should use today, given the ingredients she has on hand and the sale price of each type of smoothie.

입력

The first line contains two integers kk and rr, separated by a space. The value kk is the number of different ingredients Olivia uses in her smoothies and rr is the number of different recipes she makes. You may assume 1k100,0001 \le k \le 100\\,000, 1r100,0001 \le r \le 100\\,000, and 1kr100,0001 \le kr \le 100\\,000. The second line contains kk integers, which represent the amount of each ingredient she currently has on hand. This is followed by rr lines, each of which represents a recipe. On each such line, the first kk space-separated integers represent the amount of each ingredient used in that recipe. This is followed by one integer representing the price charged for one smoothie of that recipe.

You may assume that all values, except possibly kk and rr, are nonnegative integers less than or equal to 10410^4. It is guaranteed that each recipe uses at least one ingredient.

출력

Output the largest total sales revenue that can be obtained by choosing a single recipe and making as many of that recipe as possible.