#t535. 局域网

局域网

Local Area Network

Problem Background

Special for beginners, ^_^

Problem Description

There are nn (n≤100n \le 100) computers in a local area network. Due to carelessness when the network was built, the connections inside the LAN now form cycles. We know that if the LAN forms a cycle, data will keep circulating inside the cycle, causing the network to lag. Because the network cables connecting the computers are different, some connections are not very smooth. We use f(i,j)f(i, j) to denote the smoothness of the connection between ii and jj (f(i,j)≤1000f(i, j) \le 1000); the smaller the value of f(i,j)f(i, j), the smoother the connection between ii and jj, and f(i,j)=0f(i, j) = 0 means there is no cable connecting ii and jj.

Now we need to solve the cycle problem: we will remove some cables so that there is no cycle in the network, and the sum ∑f(i,j)\sum f(i, j) of the removed cables is maximized. Find this maximum value.

Input Format

The first line contains two positive integers nn and kk.

The following kk lines each contain three positive integers i j mi\ j\ m, meaning computers ii and jj are connected by a cable with smoothness mm.

Output Format

One positive integer: the maximum value of ∑f(i,j)\sum f(i, j).

Sample Input

5 5
1 2 8
1 3 1
1 5 3
2 4 5
3 4 2

Sample Output

8

Constraints

Time limit: 1s; memory limit: 1024 KiB for each test case.