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: Accepted)

use std::io::{self, BufReader, Read};
use std::str::FromStr;
use std::string::String;

fn main() {
	let mut sc = ::Scanner::new(io::stdin());
	let r: i32 = sc.next_as().unwrap();
	let ans = match r {
		0...1199 => "ABC",
		1200...2799 => "ARC",
		_ => "AGC"
	};
	println!("{}", ans);
}

#[derive(Debug)]
pub struct Scanner<R> {
	reader: BufReader<R>
}

impl<R: io::Read> Scanner<R> {
	
	pub fn new(read: R) -> Scanner<R> {
		Scanner { reader: BufReader::new(read) }
	}

	pub fn next_str(&mut self) -> Option<String> {
		let mut buf = [0; 1];
		let size = self.reader.read(&mut buf).unwrap();
		if size == 0 {
			None{}
		} else {
			let first = self.skip_whitespace(&mut buf);
			if first.is_none() {
				return None{}
			}
			let mut v = vec![buf[0]];
			loop {
				let size = self.reader.read(&mut buf).unwrap();
				if size == 0 || char::from(buf[0]).is_whitespace() {
					break;
				}
				v.push(buf[0]);
			}
			Some(String::from_utf8(v).unwrap())
		}
	}

	pub fn next_line(&mut self) -> Option<String> {
		let mut buf = [0; 1];
		let mut v :Vec<u8> = vec![];
		let mut size = self.reader.read(&mut buf).unwrap();
		if size == 0 {
			return None{}
		}
		loop {
			if size == 0 || char::from(buf[0]) == '\n' {
				return Some(String::from_utf8(v).unwrap())
			}
			v.push(buf[0]);
			size = self.reader.read(&mut buf).unwrap();
		}
	}

	pub fn next_vec<S: FromStr>(&mut self, size: u32) -> Vec<S> {
		let mut v: Vec<S> = vec![];
		for _ in 0..size {
			let token = self.next_str().unwrap();
			v.push(S::from_str(&token).ok().unwrap());
		}
		v
	}

	pub fn next_as<S: FromStr>(&mut self) -> Option<S> {
		if let Some(s) = self.next_str() {
			if let Ok(v) = S::from_str(&s) {
				return Some(v)
			}
		}
		None{}
	}

	pub fn next_i32(&mut self) -> Option<i32> {
		self.next_as::<i32>()
	}

	pub fn next_i64(&mut self) -> Option<i64> {
		self.next_as::<i64>()
	}

	pub fn next_f32(&mut self) -> Option<f32> {
		self.next_as::<f32>()
	}

	pub fn next_f64(&mut self) -> Option<f64> {
		self.next_as::<f64>()
	}

	fn skip_whitespace(&mut self, mut buf: &mut [u8]) -> Option<u8> {
		loop {
			if !char::from(buf[0]).is_whitespace() {
				return Some(buf[0])
			}
			let size = self.reader.read(&mut buf).unwrap();
			if size == 0 {
				return None{}
			}
		}
	}
}