#d1109. Minimum Or Spanning Tree
Minimum Or Spanning Tree
Minimum OR Spanning Tree
Problem Description
You are given an undirected graph with vertices and edges. Each edge connects vertices and and has weight . Compute the minimum cost of a spanning tree of the graph.
In this problem, the cost of a spanning tree is defined as the bitwise OR of the weights of all its edges.
Input Format
The first line contains two integers and , where is the number of vertices and is the number of edges.
The next lines each contain three integers , indicating an edge of weight between vertices and .
Output Format
Output one line containing the minimum cost of a spanning tree.
Sample Input
5 7
4 2 7
2 5 8
3 4 2
3 2 1
2 4 2
4 1 2
1 2 2
Sample Output
10
Constraints
, , . At least one spanning tree is guaranteed to exist.