3392. Antonym Of Major

Description

It is believed that everyone joined the match knows about the Minimum Spanning Tree.

A minimum spanning tree of an edge-weighted graph is a spanning tree whose weight (the sum of the weights of its edges) is no larger than the weight of any other spanning tree, and is also a connected acyclic subgraph of the graph.

In other words, keep  edges of the graph, ensure the connectivity of the graph, and minimize the sum of edge weights.

Now given a connected undirected edge-weighted graph, we define POWOR as the bitwise OR of edge weights of the spanning tree of this graph, and want to keep that POWOR as small as possible. You need to find the minimum POWOR .

Input

The first line is two integers  and , representing the number of vertices in the graph and the number of edges in the graph, respectively.

The next  lines contain the description of the edges. Linecontains three numbers,and, representing the two vertices and edge weights of an edge in the graph, respectively.

Output

Output a single line with an integer representing the minimum POWOR.

Sample Input

3 3
1 2 1
1 3 2
2 3 4

Sample Output

3

Note

 


难度等级: 0
总通过次数: 20
总提交次数: 154