Merchant
A merchant deals in three types of goods: diamonds, apples, and silk. For each product, the cost in gold coins per unit weight and the quantity available with the merchant are known.
In the merchant's country, there are N cities, numbered from 1 to N. The merchant's hometown is city 1, and the capital is city N. To sell his goods in the capital, the merchant must travel through various cities. There are roads connecting some pairs of cities, and traveling these roads incurs a certain cost in gold. Additionally, each city imposes a tax on transporting each type of good, calculated as a percentage of the goods' value. Once the merchant leaves a city, he cannot return. Each pair of cities is connected by at most one road.
The merchant aims to maximize his profit, which is the difference between the revenue from selling the goods in the capital and the expenses incurred during the journey. He is not required to transport all his goods. The merchant always has enough gold to pay the taxes and cannot use the goods he is transporting to settle these payments. All roads are one-way.
Write a program that, given the quantities of each type of goods the merchant possesses, their prices in the capital, the taxes in the cities, the roads between the cities, and the travel costs, calculates the maximum profit the merchant can achieve from selling the goods.
Input
The first line contains two integers N (2 ≤ N ≤ 500) and M (M ≥ 1) — the number of cities and roads between them. The second line contains three non-negative integers representing the quantities of diamonds, apples, and silk the merchant owns. The third line contains three non-negative integers — the cost per unit weight of diamonds, apples, and silk, respectively. Lines 4 to N + 1 each contain three integers from 0 to 100, indicating the percentage tax on diamonds, apples, and silk in cities 2 to N - 1. The merchant's hometown 1 and the capital N do not impose taxes. The next M lines each contain three non-negative integers: the first two, ranging from 1 to N, specify a pair of cities connected by a road, and the third is the travel cost on that road. Roads lead from the first city listed to the second. The quantities of goods, their prices, and the travel costs do not exceed 100.
Output
Output a single number — the exact value of the maximum profit from the trip to the capital. The result must be formatted to exactly two decimal places. If the merchant cannot make a profit or reach the capital with the available roads, output 0.00.