Minimum Cost Roads

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

As the newly elected mayor of Kitchener, Alanna's first job is to improve the city's road plan.

Kitchener's current road plan can be represented as a collection of NN intersections with MM roads, where the ii-th road has length l_il\_i meters, costs c_ic\_i dollars per year to maintain, and connects intersections u_iu\_i and v_iv\_i. To create a plan, Alanna must select some subset of the MM roads to keep and maintain, and that plan's cost is the sum of maintenance costs of all roads in that subset.

To lower the city's annual spending, Alanna would like to minimize the plan's cost. However, the city also requires that she minimizes travel distances between intersections and will reject any plan that does not conform to those rules. Formally, for any pair of intersections (i,j)(i, j), if there exists a path from ii to jj taking ll meters on the existing road plan, Alanna's plan must also include a path between those intersections that is at most ll meters.

입력

The first line contains the integers NN and MM.

Each of the next MM lines contains the integers u_iu\_i, v_iv\_i, l_il\_i, and c_ic\_i, meaning that there currently exists a road from intersection u_iu\_i to intersection v_iv\_i with length l_il\_i and cost c_ic\_i (1u_i,v_iN,u_iv_i)(1 \le u\_i, v\_i \le N, u\_i \neq v\_i).

출력

Output one integer, the minimum possible cost of a road plan that meets the requirements.

제한

  • 1N,M2,0001 \le N, M \le 2\\,000
  • 0l_i1090 \le l\_i \le 10^9
  • 1c_i1091 \le c\_i \le 10^9