Global Maximum Cut#4352

Global Maximum Cut

2 seconds
256 megabytes
Very easy

Given an undirected graph where each edge has an associated cost, your task is to determine the value of the global maximum cut.

Input

The first line of the input contains two integers, and , representing the number of vertices and edges in the graph, respectively (2 \leq n \leq 1000, 1 \leq m \leq 30000). The following lines each describe an edge with three integers , , and , indicating that there is an edge between vertices and with a cost of (0 \leq c \leq 10^9).

Output

Print the value of the global maximum cut.

Examples

Example 1

Loading
Loading