#K53477. Max Square Plots
Max Square Plots
Max Square Plots
You are given a field with dimensions \(L\) (length) and \(W\) (width). Farmer John wants to partition his field into the largest possible square plots such that the squares exactly tile the entire field without any leftover area. The side length \(s\) of the square plots is determined by the greatest common divisor (\(gcd\)) of \(L\) and \(W\). Once \(s\) is computed, the field can be divided into \(\frac{L}{s} \times \frac{W}{s}\) square plots. Your task is to calculate both \(s\) and the number of square plots for each test case.
Formally, if \(s = gcd(L, W)\), then the number of plots is given by \[ \frac{L}{s} \times \frac{W}{s} \]
inputFormat
The first line of input contains an integer \(T\), representing the number of test cases. Each of the following \(T\) lines contains two space-separated integers \(L\) and \(W\) indicating the length and width of the field respectively.
outputFormat
For each test case, output two space-separated integers: the side length of the largest square plot and the number of such square plots that can be obtained.
## sample2
15 10
12 16
5 6
4 12
</p>