Problem:
Score : 100 points

Problem Statement

A programming competition site AtCode regularly holds programming contests.

The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.

The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800.

The contest after the ARC is called AGC, which is rated for all contestants.

Takahashi's rating on AtCode is R. What is the next contest rated for him?

Constraints

0 ≤ R ≤ 4208

R is an integer.

Input

Input is given from Standard Input in the following format:

R

Output

Print the name of the next contest rated for Takahashi (ABC, ARC or AGC).

Sample Input 1

1199

Sample Output 1

ABC

1199 is less than 1200, so ABC will be rated.

Sample Input 2

1200

Sample Output 2

ARC

1200 is not less than 1200 and ABC will be unrated, but it is less than 2800 and ARC will be rated.

Sample Input 3

4208

Sample Output 3

AGC

Solution in Rust (1.15.1) (judge verdict: Wrong Answer)

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let s: String = read();
    let s = s.chars().collect::<Vec<char>>();
    let mut dp: Vec<Vec<i64>> = vec![vec![0; 4]; s.len() + 1];
    let big_num: i64 = 1000_0000 + 7;
    dp[0][0] = 1;
    for i in 0..s.len() {
        for j in 0..4 {
            if s[i] == '?' {
                dp[i + 1][j] = (dp[i + 1][j] + 3 * dp[i][j]) % big_num;
            } else {
                dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % big_num;
            }
            if (s[i] == 'A' && j == 0)
                || (s[i] == 'B' && j == 1)
                || (s[i] == 'C' && j == 2)
                || (s[i] == '?')
            {
                if j != 3 {
                    dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % big_num;
                }
            }
        }
    }
    // println!("{:?}", dp);
    println!("{:?}", dp[s.len()][3]);
}