Nogcd
시간 제한1초메모리 제한1024 MB
연결 그래프의 각 간선에 1부터 M까지 서로 다른 정수를 붙이되, 차수가 1보다 큰 모든 정점에서 이웃 간선 레이블의 최대공약수가 1이 되게 하라.
문제
Boss, if , you should try to optimise the solution. (Friedrich Nietzsche)
Let be a undirected connected graph with nodes and edges. Label each of the edges with a distinct integer from to . For each node with degree greater than , the greatest common divisor of its incident edges' labels should be .
입력
The first line contains two integers and .
The next lines contain two integers and , representing two nodes that share an edge.
출력
Print lines, each containing three integers , and corresponding to an edge with label between and .
제한
- There are no self-loops or multiple edges in the graph.