You are given a directed graph with n nodes and m edges. The nodes are numbered from 1 to n, and node i is assigned a cost ci. The cost of a walk on the graph is defined as the greatest common divisor of the costs of the vertices used in the walk. Formally, the cost of a walk v1,v2,⋯,vk is given by gcd(cv1,cv2,⋯,cvk). Note that vi's need not be distinct. Find the cost of the walk with minimum cost.
The walk might consist of single vertex.
Input
Output
Constraints
You can choose the walk 1→2→3 to get a gcd of 2