N people want to buy the same book. The people are numbered 1 to N, and person j wants Aj copies. M online stores sell the book. The stores are numbered 1 to M, and store i holds Bi copies.
These N people are the only buyers, and the total number of copies the stores hold equals the total number of copies the people want.
How many copies one person buys from one store is limited. Person j can buy at most Cij copies from store i. Given every purchase limit between a store and a person, write a program that finds the largest number of copies that can be bought.
The first line contains the number of people N and the number of online stores M. (1≤N,M≤100)
The second line contains A1,A2,…,AN, the number of copies each person wants. (1≤Aj≤100)
The third line contains B1,B2,…,BM, the number of copies each store holds. (1≤Bi≤100)
Each of the next M lines contains N numbers and gives the purchase limits. The j-th number on the i-th line is Cij, the largest number of copies person j can buy from store i. (0≤Cij≤100)
A1+⋯+AN=B1+⋯+BM holds.
Print the largest number of copies that can be bought.