#K62842. Build the Barn Problem
Build the Barn Problem
Build the Barn Problem
Given a rectangular field with dimensions N and M, determine if it is possible to construct a barn (also rectangular) with an exact area of \(K\) where the sides of the barn are integers. The barn must fit entirely within the field. In other words, there must exist two positive integers \(a\) and \(b\) such that:
- \(a \times b = K\)
- Either \(a \leq N\) and \(b \leq M\) or \(a \leq M\) and \(b \leq N\)
Your task is to answer whether the barn with area \(K\) can be built in the given field. Print POSSIBLE
if it can be built, otherwise print IMPOSSIBLE
.
inputFormat
The first line of input contains a single integer T denoting the number of test cases. Each of the next T lines contains three integers N, M, and K, where N and M represent the dimensions of the field and K is the required area for the barn.
Input is read from standard input (stdin).
outputFormat
For each test case, output a single line: POSSIBLE
if it is possible to build the barn, or IMPOSSIBLE
otherwise. Output is written to standard output (stdout).
3
5 4 6
3 3 10
4 4 16
POSSIBLE
IMPOSSIBLE
POSSIBLE
</p>