Galactic Taxes

Find the moment of the day that maximizes the cheapest path cost from office 1 to N when each edge tax changes linearly with time.

Medium7Shortest pathBinary searchNo attempts yetTime limit3sMemory limit256 MB

Problem

The year is 2115. The Interplanetary Commercial Planning Center (ICPC) is supported by the Autonomous Communication Ministry (ACM).

A commercial operation runs transactions between connected ACM offices across the galaxy. One transaction between two connected offices costs a tax that grows or shrinks continuously with the time of day, given by the linear function A×t+BA \times t + B, where tt is a real number of minutes and 0t24×600 \le t \le 24 \times 60. The tax is never negative.

The total tax of a commercial operation carried out at time tt between the source office and the destination office is the smallest possible sum of transaction taxes along a path from the source office to the destination office. Every transaction on that path is taxed at the same time tt.

The taxes keep changing all day, so ACM picks the one moment that makes the collected total tax as large as possible and performs the commercial operation exactly then, not earlier and not later.

Given the network of ACM offices, print the largest total tax ACM can collect during the day.

Input

The first line contains two integers NN and MM, the number of ACM offices and the number of connections (2N10002 \le N \le 1000, 1M1041 \le M \le 10^4). The offices carry distinct numbers from 1 to NN. Office 1 is the source office and office NN is the destination office.

Each of the next MM lines describes one connection with four integers II, JJ, AA, BB (1I<JN1 \le I < J \le N, 100A100-100 \le A \le 100, 0B1060 \le B \le 10^6). Offices II and JJ are connected in both directions, and a transaction between them at time tt is taxed A×t+BA \times t + B. Taxes are never negative, so A×t+B0A \times t + B \ge 0 holds for every tt with 0t24×600 \le t \le 24 \times 60. At most one connection joins a given pair of offices, and at least one path runs from the source office to the destination office.

Output

Print, on one line, the largest total tax ACM can collect during the day. Write exactly five digits after the decimal point. If the value has more digits, round half up at the fifth one.