Under construction

Still being built. Things may change

Factorization of Quadratic Formula

Interview

Time limit1sMemory limit1024 MB

Summary
Given integers a, b, c of ax^2 + bx + c, find integers p, q, r, s so that it equals (px + q)(rx + s), or report Impossible.
Level

Medium4 of 10

Topics
Math, Brute force, Implementation
Solved
No attempts yet

Problem

As the first step in algebra, students learn quadratic formulas and their factorization. Factorization is often a heavy burden for them. A large number of students never master it, so they cannot appreciate the elegance of advanced algebra. Factorization may even increase the number of people who hate mathematics.

This problem asks you to write a program that helps students in an algebra course. Given a quadratic formula, the program reports whether it can be factorized into two linear formulas, and if so, gives the factorization. All coefficients in this problem are integers.

The coefficients aa, bb, and cc of the quadratic formula ax2+bx+cax^2 + bx + c are given. They are integers with absolute values at most 10000. The program must find integers pp, qq, rr, and ss such that ax2+bx+c=(px+q)(rx+s)ax^2 + bx + c = (px + q)(rx + s). Since only integer coefficients are allowed, some formulas cannot be factorized this way. In that case, the program reports that the factorization is impossible.

Input

The input is a sequence of lines, each describing one quadratic formula. Each line has the format

aa bb cc

where aa, bb, and cc are integers separated by spaces. They satisfy the following inequalities.

0<a≤100000 \lt a \le 10000

−10000≤b≤10000-10000 \le b \le 10000

−10000≤c≤10000-10000 \le c \le 10000

The greatest common divisor of aa, bb, and cc is 1. No integer kk greater than 1 divides all three.

The end of input is a line containing three 0's.

Output

For each input line, print the four integers pp, qq, rr, and ss on one line, in this order, if a factorization exists. Separate the integers with one or more spaces. If the factorization is impossible, print only the word "Impossible".

The four coefficients must satisfy the following conditions.

p>0p > 0

r>0r > 0

p>rp > r, or p=rp = r and q≥sq \ge s

These conditions, together with the fact that the greatest common divisor of aa, bb, and cc is 1, make the answer unique. Once you find a factorization, you do not need to look for another one.

Examples1

  1. Example 1

    Input
    2 5 2
    1 1 1
    10 -7 0
    1 0 -3
    0 0 0
    
    Expected output
    2 1 1 2
    Impossible
    10 -7 1 0
    Impossible