APGPTUT - APGP Tutorial

Arithmetic Progression is the series in which every next term is at common difference from the previous term, e.g.: 1 2 3 4, where the common difference is 1.

Geometric Progression is one in which every next term of the series is obtained by multiplying the previous term with a constant, e.g. 1 2 4 8, where the common ratio is 2.

Your task is to find the series and print its next term..

Input

The input will contain three numbers (0 <= a, b, c <= 10^15) denoting the three consecutive terms of the series.
Input is terminated when all the three numbers are 0.

Output

Output for each test case will contain the name of the series i.e. AP or GP and the value of the next term of the series.

Example

Input:
10 15 20
5 10 20
0 0 0 Output: AP 25
GP 40

Added by:Rajesh Kumar
Date:2012-09-02
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:ASM32-GCC MAWK BC C-CLANG C NCSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GOSU GRV JAVA JS-MONKEY JULIA KTLN NIM NODEJS OBJC OBJC-CLANG OCT PICO PROLOG PYPY PYPY3 PY_NBC R RACKET RUST CHICKEN SQLITE SWIFT UNLAMBDA VB.NET

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.