Cheapest Closed Route

No attempts yetTime limit1sMemory limit128 MB

Problem

Byteasar is planning an excursion through Byteland. Some pairs of cities are joined by two-way bus connections. Byteasar wants a trip that starts and ends in the same city and never uses the same bus connection twice: once he has ridden the connection between two cities in either direction, he will not ride that connection again. The fare of such a closed route is the sum of the fares of the connections it uses.

Among all non-empty closed routes that use no bus connection more than once, find the smallest possible total fare, or report that no such route exists.

Input

The first line contains two integers nn and mm separated by a single space (1n5001 \le n \le 500, 0m500000 \le m \le 50000): the number of cities and the number of two-way bus connections.

Each of the next mm lines contains three integers xix_i, yiy_i and cic_i (1xi,yin1 \le x_i, y_i \le n, xiyix_i \ne y_i, 1ci1000001 \le c_i \le 100000): a connection between cities xix_i and yiy_i with fare cic_i. Each pair of cities is joined by at most one connection.

Output

Print a single line with the minimum possible total fare of a non-empty closed route that uses no bus connection more than once. If no such route exists, print BRAK instead.