Many Many Cycles
시간 제한2초메모리 제한2048 MB
가중 무향 그래프에서 모든 단순 사이클 길이의 공통 약수 중 가장 큰 d를 구하고, 없으면 0을 출력한다.
문제
Consider an undirected graph . Find the maximal number such that the lengths of all simple cycles are divisible by . If there is no such number, output .
입력
The first line contains two integers and : the number of vertices and edges (, ). Each of the next lines contains three integers , , and , which mean that there is a bidirectional edge between vertices and with length (, ). It is guaranteed that the graph doesn't contain loops or multiple edges.
출력
Print one integer: the answer to the problem.