#K45587. Smallest Right-Angled Triangle

    ID: 27786 Type: Default 1000ms 256MiB

Smallest Right-Angled Triangle

Smallest Right-Angled Triangle

Given two integers m and n, determine whether these two numbers can form the two legs of a right-angled triangle with integer sides based on the Pythagorean theorem, i.e. \( m^2 + n^2 = h^2 \) for some integer \( h \). If such a triangle exists, output the three side lengths in ascending order; otherwise, output -1.

Note that the input numbers may be provided in any order, but the triangle’s sides must always be returned in ascending order.

inputFormat

The input consists of two integers separated by spaces in a single line representing the two sides \( m \) and \( n \) of the potential right-angled triangle.

outputFormat

If a valid right-angled triangle with integer sides can be formed from the given legs, output the three side lengths in ascending order separated by spaces. Otherwise, output -1.

## sample
5 12
5 12 13