#K64497. Longest Square Side

    ID: 31988 Type: Default 1000ms 256MiB

Longest Square Side

Longest Square Side

You are given a set of rectangles. For each rectangle with dimensions (l) and (w), compute the greatest common divisor ((\gcd(l, w))). The task is to find the maximum value among these (\gcd(l, w)) values, which represents the side length of the largest possible square that can be formed such that its side is a divisor of at least one rectangle's dimensions. This problem tests your ability to work with basic arithmetic operations and the (\gcd) function.

inputFormat

The input is given via standard input (stdin). The first line contains a single integer (n) representing the number of rectangles. Each of the following (n) lines contains two space-separated positive integers (l) and (w), representing the dimensions of a rectangle.

outputFormat

Output to standard output (stdout) a single integer representing the maximum (\gcd(l, w)) among all the rectangles.## sample

3
6 9
4 3
8 12
4