Next Number

No attempts yetTime limit1sMemory limit128 MB

Problem

An arithmetic progression (AP) is a sequence in which the difference between two adjacent terms (the common difference) is constant. For example, 3, 5, 7, 9, 11, 13, … is an arithmetic progression whose common difference is a constant 2. In this problem the common difference is always a nonzero integer.

A geometric progression (GP) is a sequence in which the ratio between two adjacent terms (the common ratio) is constant. For example, 2, 6, 18, 54, … is a geometric progression with a common ratio of 3. In this problem the common ratio is always a nonzero integer.

Given three consecutive terms of a sequence, determine whether the sequence is an arithmetic progression or a geometric progression, then compute its next term.

Input

The input consists of several test cases. Each test case is a single line containing three consecutive integers of the sequence, $a_1$, $a_2$, $a_3$ ($-10000 < a_1, a_2, a_3 < 10000$). The three integers are all distinct.

The last line of the input contains three zeros and must not be processed.

Output

For each test case, print AP if the sequence is an arithmetic progression or GP if it is a geometric progression, followed by the next term. Every input is always either an arithmetic or a geometric progression.