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 Java8 (OpenJDK 1.8.0) (judge verdict: Runtime Error)

//「全問解く」:1一問も解かない」:0 としてBIT全探索→scoreに値を代入
//例.d=4,i=1011なら「100点、200点、400点の問題を全部解く」
//もしscoreがgに満たなかったら、iのビットを桁が大きいほうからしらべて0ならばその得点の問題を1問ずつ解く
//一問解くたびにscore>=gを確認し、真なら最小値と比較、最小値を下回れば更新しループを抜ける
//もし各回においてscore<gなら、p-1回まで行う
//このようなビットは高々1つでよい（p問解くならそのビットが1になっているのと同じである）
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int d=sc.nextInt();
        int g=sc.nextInt();
        int[] p=new int[d+1];
        int[] c=new int[d+1];
        for (int i = 0; i < d; i++) {
            p[i+1]=sc.nextInt();
            c[i+1]=sc.nextInt();
        }
        int ans=1000000000;
        for (int i = 0; i < (1 << d); i++) {
            //temp:iを決めた時の回答数
            //score:iを決めた時の得点
            int temp=0;
            long score=0;
            for (int j = 0; j < d; j++) {
                if((1&(i>>j))==1) {
                    score += (j + 1) * 100 * p[j + 1] + c[j + 1];
                    temp += p[j + 1];
                }
            }
            if(score>=g){
                ans=min(ans,temp);
            }else {
                //高得点の問題から貪欲をする
                for (int j = d-1; j > -1; j--) {
                    if((1&(i>>j))==1)continue;
                    else {
                        for (int k = 1; k < p[j + 1]; k++) {
                            score += (j + 1) * 100;
                            temp += 1;
                            if(score>=g) {
                                ans = min(ans, temp);
                                break;
                            }
                        }
                        break;
                    }
                }
            }
        }
        out.println(ans);
    }
}