PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#FW0000092. Người bán hàng với cạnh âm (Negative Traveling Salesman)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Người bán hàng với cạnh âm (Negative Traveling Salesman)

Negative Traveling Salesman

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

Given a directed weighted graph with possibly negative edges but no negative cycles, find a walk visiting every vertex at least once with minimum total weight. Vertices and edges may be revisited. Print exactly No if no such walk exists.

Input

First line n,mn,m, followed by mm directed edges u,v,wu,v,w with 1-indexed vertices.

Output

Print the minimum total edge weight or No.

Subtasks

  • Subtask 1 (40 points): 2≤n≤6,  −40≤w≤702\le n\le 6,\;-40\le w\le 70. All input-format and graph conditions above apply.

  • Subtask 2 (60 points): 2≤n≤12,  −40≤w≤702\le n\le 12,\;-40\le w\le 70. All input-format and graph conditions above apply.

Examples

Input

2 1
1 2 -3

Output

-3

Explanation

Start at node 1 and take edge 1 to 2 with weight −3-3. Both nodes are visited, and there is no alternative walk of lower total cost, giving −3-3.