eolymp
bolt
Try our new interface for solving problems
Problems

Tariffs

Tariffs

Nowadays practically every mobile operator has a wide range of tariffs that allows each person to choose the most suitable one for himself. Unfortunately to carry out it manually is a very difficult choice.

One mobile operator characterize each tariff with three numbers: the subscription fee ci (in rubles), the minimal tariffed time unit ti (in seconds), the cost of minimum tariffed unit of time pi (in kopecks, one ruble contains 100 kopecks). The total cost of calls for the month consists of the subscription fee and the cost of each outgoing call. The cost of the call when using the i-th tariff is calculated as follows: let the call time equals to T seconds. If T < ti, then the cost of the call equals to zero. Otherwise, the cost of the call equals to the product of k by pi, where k the minimum integer such that k · tiT.

The description of tariffs and statistics of outgoing phone calls in a month are given. The number of calls is m, their durations are d1, ..., dm in seconds. Find the tariff when the total cost of all these calls would be minimal.

Input

First line contains two integers n and m - respectively the number of tariffs and number of outgoing phone calls (1n, m100). Each of the next n lines describes one tariff and contains three integers: ci (0ci100), ti (1ti3600), pi (0pi1000).

The last line contains m integers d1, ..., dm (1di3600 for all i from 1 to m).

Output

Print the tariff number, using which the total cost of outgoing calls during the reporting month is minimal. The tariffs are numbered with integers from 1 to n in the same order like they are given at input. If there are many such tariffs, print any of them.

Time limit 1 second
Memory limit 122.49 MiB
Input example #1
2 1
100 60 100
51 10 100
600
Output example #1
1
Source Russian-Code-Cup-2011 1-й кв. раунд