# PROBLEM LINK:

Practice

Contest: Division 1

Contest: Division 2

Contest: Division 3

Contest: Division 4

* Author:* pols_agyi_pols

*iceknight1093*

**Tester & Editorialist:**# DIFFICULTY:

802

# PREREQUISITES:

None

# PROBLEM:

Given integers X, Y, and Z, find any two integers A and B such that:

- B equals one of the three numbers;
- A equals the product of the remaining two numbers;
- B divides A.

# EXPLANATION:

B must be equal to one of X, Y, Z, which means there are only three choices for what B can be.

Once B is fixed, A is also fixed, being the product of the remaining elements.

It’s thus enough to just try all three options for B using `if`

conditions.

That is,

- If X divides (Y\cdot Z), then you can choose A = Y\cdot Z and B = X
- If Y divides (X\cdot Z), then you can choose A = X\cdot Z and B = Y
- If Z divides (X\cdot Y), then you can choose A = X\cdot Y and B = Z
- If all three checks fail, the answer is -1.

# TIME COMPLEXITY

\mathcal{O}(1) per testcase.

# CODE:

## Editorialist's code (Python)

```
for _ in range(int(input())):
x, y, z = map(int, input().split())
if (y * z) % x == 0: print(y*z, x)
if (x * z) % y == 0: print(x*z, y)
elif (x * y) % z == 0: print(x*y, z)
else: print(-1)
```