NOI Contest Archive

Archive / 2021 / April 2021

Minimal Cost

Medium · National Olympiad in Informatics Sri Lanka - April 2021

You are given a set of cities( numbered from 1 to N ) that are connected with directed roads. Each city has a value assigned to it. Your task is to find a path such that minimizes the Great Common Devisor in the values of the cities on the path and output that minimum GCD value.

There can be a path that contains only one city.

Input Format

Output Format

Print the minimum GCD value you found.

Constraints

Sample Input 0

3 2
4 6 8
1 2
2 3

Sample Output 0

2