Lavrenty, a baker, is going to make several buns with stuffings and sell them.

Lavrenty has *n* grams of dough as well as *m* different stuffing types. The stuffing types are numerated from 1 to *m*. Lavrenty knows that he has *a*_{i} grams left of the *i*-th stuffing. It takes exactly *b*_{i} grams of stuffing *i* and *c*_{i} grams of dough to cook a bun with the *i*-th stuffing. Such bun can be sold for *d*_{i} tugriks.

Also he can make buns without stuffings. Each of such buns requires *c*_{0} grams of dough and it can be sold for *d*_{0} tugriks. So Lavrenty can cook any number of buns with different stuffings or without it unless he runs out of dough and the stuffings. Lavrenty throws away all excess material left after baking.

Find the maximum number of tugriks Lavrenty can earn.

提交代码