#K65792. Largest Square Plot
Largest Square Plot
Largest Square Plot
You are given the dimensions of a farm as two integers \(L\) and \(W\), representing the length and width respectively. Your task is to determine the side length of the largest square plot that can be cut from the farm such that the entire farm can be exactly divided into these square plots without any leftovers.
Mathematically, the side length of the square plot is the greatest common divisor (GCD) of \(L\) and \(W\). That is, if \(g = \gcd(L, W)\), then the farm can be divided into \(\frac{L}{g} \times \frac{W}{g}\) square plots each of side length \(g\).
Note: The input begins with an integer \(T\) representing the number of test cases. Each test case consists of two integers \(L\) and \(W\).
inputFormat
The input is read from standard input (stdin) as follows:
- An integer \(T\) denoting the number of test cases.
- For each test case, a line containing two space-separated integers \(L\) and \(W\) representing the dimensions of the farm.
outputFormat
For each test case, output a single line containing the side length of the largest square plot (i.e., the greatest common divisor of \(L\) and \(W\)).
## sample2
15 20
21 28
5
7
</p>