The Bitlandians are quite weird people. They have very peculiar customs.

As is customary, Uncle J. wants to have n eggs painted for Bitruz (an ancient Bitland festival). He has asked G. and A. to do the work.

The kids are excited because just as is customary, they're going to be paid for the job! 

Overall uncle J. has got n eggs. G. named his price for painting each egg. Similarly, A. named his price for painting each egg. It turns out that for each egg the sum of the money both A. and G. want for the painting equals 1000.

Uncle J. wants to distribute the eggs between the children so as to give each egg to exactly one child. Also, Uncle J. wants the total money paid to A. to be different from the total money paid to G. by no more than 500.

Help Uncle J. Find the required distribution of eggs or otherwise say that distributing the eggs in the required manner is impossible.


-----Input-----

The first line contains integer n (1 ≤ n ≤ 10^6) — the number of eggs.

Next n lines contain two integers a_{i} and g_{i} each (0 ≤ a_{i}, g_{i} ≤ 1000; a_{i} + g_{i} = 1000): a_{i} is the price said by A. for the i-th egg and g_{i} is the price said by G. for the i-th egg.


-----Output-----

If it is impossible to assign the painting, print "-1" (without quotes).

Otherwise print a string, consisting of n letters "G" and "A". The i-th letter of this string should represent the child who will get the i-th egg in the required distribution. Letter "A" represents A. and letter "G" represents G. If we denote the money Uncle J. must pay A. for the painting as S_{a}, and the money Uncle J. must pay G. for the painting as S_{g}, then this inequality must hold: |S_{a}  -  S_{g}|  ≤  500. 

If there are several solutions, you are allowed to print any of them.


-----Examples-----
Input
2
1 999
999 1

Output
AG

Input
3
400 600
400 600
400 600

Output
AGA

Difficulty: MEDIUM

Solutions:
from sys import *
input = stdin.readline
n = int(input())
r = []
(x, y) = (0, 0)
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
for i in range(n):
	if abs(x + l[i][0] - y) <= 500:
		r.append('A')
		x += l[i][0]
	else:
		y += l[i][1]
		r.append('G')
if abs(x - y) <= 500:
	print(''.join(r))
else:
	print(-1)


from sys import stdin, stdout
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, stdin.readline().split()))
for i in range(1):
	n = nmbr()
	sma = 0
	smb = 0
	ans = []
	for i in range(n):
		(a, b) = lst()
		if abs(a + sma - smb) <= 500:
			sma += a
			ans += ['A']
		else:
			smb += b
			ans += ['G']
	stdout.write(''.join(ans))


n = int(input())
a = 0
g = 0
s = ''
for _ in range(n):
	(x, y) = map(int, input().split())
	if a + x - g <= 500:
		s = s + 'A'
		a += x
	elif g + y - a <= 500:
		s = s + 'G'
		g += y
	else:
		print(-1)
		exit()
print(s)


t = int(input())
s = ''
x = 0
y = 0
for i in range(t):
	(c, d) = map(int, input().split())
	if y + c - x <= 500:
		y += c
		s += 'A'
	else:
		x += d
		s += 'G'
print(s)


import sys
n = int(sys.stdin.readline())
sumA = 0
for i in range(n):
	(a, g) = map(int, sys.stdin.readline().split())
	if sumA + a <= 500:
		print('A', end='')
		sumA += a
	else:
		print('G', end='')
		sumA -= g


import math
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
sum = 0
for _ in range(int(input())):
	(a, g) = map(int, input().split())
	if sum + a <= 500:
		sum += a
		print('A', end='')
	else:
		sum -= g
		print('G', end='')


import sys
s = ''
n = int(sys.stdin.readline())
(a, g) = (0, 0)
for i in range(n):
	(x, y) = map(int, sys.stdin.readline().split())
	if abs(a + x - g) <= 500:
		s += 'A'
		a += x
	else:
		s += 'G'
		g += y
print(s)


import bisect
from itertools import accumulate
import os
import sys
import math
from decimal import *
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def SieveOfEratosthenes(n):
	prime = []
	primes = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if primes[p] == True:
			prime.append(p)
			for i in range(p * p, n + 1, p):
				primes[i] = False
		p += 1
	return prime

def primefactors(n):
	fac = []
	while n % 2 == 0:
		fac.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 2):
		while n % i == 0:
			fac.append(i)
			n = n // i
	if n > 1:
		fac.append(n)
	return sorted(fac)

def factors(n):
	fac = set()
	fac.add(1)
	fac.add(n)
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			fac.add(i)
			fac.add(n // i)
	return list(fac)

def modInverse(a, m):
	m0 = m
	y = 0
	x = 1
	if m == 1:
		return 0
	while a > 1:
		q = a // m
		t = m
		m = a % m
		a = t
		t = y
		y = x - q * y
		x = t
	if x < 0:
		x = x + m0
	return x
n = int(input())
ans = ''
a = 0
b = 0
for i in range(n):
	(x, y) = map(int, input().split())
	if x + a - b <= 500:
		print('A', end='')
		a += x
	else:
		print('G', end='')
		b += y


from sys import stdin

def __starting_point():
	n = int(stdin.readline())
	ans = ''
	sum_a = sum_g = 0
	for _ in range(n):
		(a, g) = list(map(int, stdin.readline().split()))
		if sum_a + a <= sum_g + 500:
			ans += 'A'
			sum_a += a
		else:
			ans += 'G'
			sum_g += g
	print(ans)
__starting_point()


n = int(input())
(a, g) = (0, 0)
l = ''
for i in range(n):
	(x, y) = map(int, input().split())
	if abs(x + a - g) <= 500:
		a += x
		l += 'A'
	else:
		g += y
		l += 'G'
print(l)


n = int(input())
at = 0
gt = 0
s = []
for i in range(n):
	(a, b) = map(int, input().split())
	temp = at
	temp += a
	if abs(temp - gt) <= 500:
		at = temp
		s.append('A')
	else:
		gt += b
		s.append('G')
if abs(gt - at) > 500:
	print(-1)
else:
	print(''.join(s))


import os
import sys
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def seive(n):
	primes = [True] * (n + 1)
	ans = []
	for i in range(2, n):
		if not primes[i]:
			continue
		j = 2 * i
		while j <= n:
			primes[j] = False
			j += i
	for p in range(2, n + 1):
		if primes[p]:
			ans += [p]
	return ans

def factors(n):
	factors = []
	x = 2
	while x * x <= n:
		while n % x == 0:
			factors.append(x)
			n //= x
		if n > 1:
			factors.append(x)
	return factors

def main():
	try:
		n = inp()
		(asum, bsum) = (0, 0)
		ans = []
		for _ in range(n):
			(x, y) = invr()
			if asum + x - bsum > 500:
				ans.append('G')
				bsum += y
			else:
				ans.append('A')
				asum += x
		print(''.join(ans))
	except Exception as e:
		print(e)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
l = ['A'] * n
p = 500
for i in range(n):
	a = int(input().split()[0])
	if 0 <= p + a <= 1000:
		p += a
	else:
		l[i] = 'G'
		p -= 1000 - a
print(''.join(l))


from sys import stdin, stdout
n = int(input())
a = 0
b = 0
ans = ''
for i in range(n):
	(l, r) = map(int, stdin.readline().split())
	if a + l - b > 500:
		b += r
		ans += 'G'
	else:
		a += l
		ans += 'A'
stdout.write(ans)


n = int(input())
ma = mg = 0
s = ''
for _ in ' ' * n:
	(x, y) = map(int, input().split())
	if ma + x - mg <= 500:
		s += 'A'
		ma += x
	elif mg + y - ma <= 500:
		s += 'G'
		mg += y
if len(s) == n:
	print(s)
else:
	print(-1)


n = int(input())
ans = ''
a = 0
g = 0
for i in range(n):
	(x, y) = map(int, input().split())
	if a + x - g > 500:
		if g + y - a > 500:
			print(-1)
			exit()
		g += y
		ans += 'G'
	else:
		a += x
		ans += 'A'
print(ans)


n = int(input())
seq = ''
sum_a = 0
sum_g = 0
for _ in range(n):
	(a, g) = map(int, input().split())
	if sum_a + a - sum_g <= 500:
		sum_a += a
		seq += 'A'
	elif sum_g + g - sum_a <= 500:
		sum_g += g
		seq += 'G'
	else:
		seq = -1
		break
print(seq)


n = int(input())
l1 = []
st = ''
c = 0
for i in range(0, n):
	x = list(map(int, input().split()))
	if x[0] + c <= 500 and x[0] + c >= -500:
		st = st + 'A'
		c = c + x[0]
	else:
		st = st + 'G'
		c = c - x[1]
print(st)


n = int(input())
(a, g, s) = (0, 0, '')
for _ in range(n):
	(x, y) = map(int, input().split())
	if abs(a + x - g) <= 500:
		s += 'A'
		a += x
	else:
		s += 'G'
		g += y
print(s)


def main():
	from sys import stdin, stdout
	n = int(stdin.readline())
	(a, b) = ([], [])
	for i in range(n):
		(x, y) = list(map(int, stdin.readline().split()))
		a.append(x)
		b.append(y)
	if a[0] > b[0]:
		total = -1 * b[0]
		t = 'G'
	else:
		total = a[0]
		t = 'A'
	for i in range(1, n):
		if total + a[i] >= 500:
			total -= b[i]
			t += 'G'
		else:
			total += a[i]
			t += 'A'
	if total < -500 or total > 500:
		stdout.write('-1')
	else:
		stdout.write(t)

def __starting_point():
	main()
__starting_point()


import sys
input = sys.stdin.readline
(a, g) = (0, 0)
for _ in range(int(input())):
	r = input().split()
	r[0] = int(r[0])
	r[1] = int(r[1])
	if abs(a + r[0] - g) <= 500:
		a += r[0]
		sys.stdout.write('A')
	else:
		g += r[1]
		sys.stdout.write('G')


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
n = int(input())
sa = 0
sg = 0
for i in range(n):
	(p, q) = map(int, input().split())
	if sg + p - sa <= 500:
		sg += p
		print('A', end='')
	else:
		sa += q
		print('G', end='')


import sys
n = int(sys.stdin.readline())
ans = ''
diff = 0
for i in range(n):
	(x, y) = map(int, sys.stdin.readline().split())
	if diff + x <= 500:
		ans += 'A'
		diff += x
	else:
		ans += 'G'
		diff -= y
if abs(diff) <= 500:
	sys.stdout.write(ans)
else:
	print('-1')


(f, s) = (0, 0)
ans = ''
for _ in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	if f + a - s <= 500:
		f += a
		ans += 'A'
	else:
		s += b
		ans += 'G'
print(ans)


n = int(input())
_sum = 0
string = ''
for i in range(n):
	(A, G) = [int(i) for i in input().split(' ')]
	if abs(_sum + A) <= 500:
		_sum += A
		string += 'A'
	else:
		_sum -= G
		string += 'G'
print(string)


import sys

def get_ints():
	return map(int, I().split())

def get_list():
	return list(map(int, I().split()))

def I():
	return sys.stdin.readline()
n = int(I())
temp = 0
for i in range(n):
	(a, b) = get_ints()
	if temp + a <= 500:
		temp += a
		print('A', end='')
	else:
		temp -= b
		print('G', end='')


n = int(input())
(s, p) = (0, 0)
l = ''
for i in range(n):
	(a, b) = map(int, input().split())
	if abs(s + a - p) <= 500:
		s = s + a
		l = l + 'A'
	else:
		p = p + b
		l = l + 'G'
if s - p <= 500:
	print(l)
else:
	print('-1')


n = int(input())
a = 0
g = 0
ans = ''
while n > 0:
	(x, y) = map(int, input().split())
	if g + x - a <= 500:
		g += x
		ans += 'A'
	else:
		a += y
		ans += 'G'
	n -= 1
print(ans)


from sys import stdin, stdout
import math
input = stdin.readline

def print(*args, end='\n'):
	s = []
	for i in args:
		s.append(str(i) + ' ')
	s = ''.join(s)
	stdout.write(s + end)

def solve():
	n = int(input())
	(a, g) = (0, 0)
	ans = []
	for i in range(n):
		(p1, p2) = map(int, input().split())
		if abs(a + p1 - g) <= 500 and abs(a + p1 - g) <= abs(g + p2 - a):
			ans.append('A')
			a += p1
		elif abs(g + p2 - a) <= 500:
			ans.append('G')
			g += p2
		else:
			print(-1)
			return
	print(''.join(ans))
tt = 1
for __ in range(tt):
	solve()


from sys import stdin, stdout
input = stdin.readline
n = int(input())
(at, gt) = (0, 0)
ans = ''
for i in range(n):
	(a, g) = map(int, input().split())
	if abs(at + a - gt <= 500):
		at += a
		print('A', end='')
	else:
		gt += g
		print('G', end='')
print()


a = int(input())
sumA = 0
sumG = 0
s = ''
for i in range(a):
	(c, d) = map(int, input().split())
	if sumA + c - 500 > sumG:
		s += 'G'
		sumG += d
	else:
		s += 'A'
		sumA += c
if abs(sumA - sumG) > 500:
	print(-1)
else:
	print(s)


from sys import stdin
eggs = []
ans = []
for line in stdin:
	data = line.strip().split()
	if len(data) == 2:
		eggs.append(tuple((int(x) for x in data)))
(A, G) = (0, 0)
for (a, g) in eggs:
	if abs(A + a - G) <= 500:
		A += a
		ans.append('A')
	else:
		G += g
		ans.append('G')
if abs(A - G) <= 500:
	print(*ans, sep='')
else:
	print(-1)


n = int(input())
a = 0
g = 0
k = []
while n > 0:
	(r1, r2) = map(int, input().split(' '))
	if g + r1 - a <= 500:
		g += r1
		k.append('A')
	else:
		a += r2
		k.append('G')
	n -= 1
print(''.join(k))


from sys import stdin
_data = iter(stdin.read().split('\n'))
input = lambda : next(_data)
n = int(input())
ans = ''
sum_a = sum_g = 0
for _ in range(n):
	(a, g) = map(int, input().split())
	if sum_a + a <= sum_g + 500:
		ans += 'A'
		sum_a += a
	else:
		ans += 'G'
		sum_g += g
print(ans)


import sys
input = lambda : sys.stdin.readline()
n = int(input())
S = 0
ans = ''
for i in range(n):
	(a, g) = [int(x) for x in input().split(' ')]
	if abs(S + a) <= 500:
		S += a
		ans += 'A'
	else:
		S -= g
		ans += 'G'
print(ans)


n = int(input())
a = 0
g = 0
str_ = ''
for i in range(n):
	input_line = input().split()
	(PenizeA, PenizeG) = (int(input_line[0]), int(input_line[1]))
	if g + PenizeA - a <= 500:
		str_ = str_ + 'A'
		g += PenizeA
	else:
		str_ = str_ + 'G'
		a += PenizeG
print(str_)


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
n = ii1()
res = ''
a = b = 0
for _ in range(n):
	(x, y) = iia()
	if abs(a + x - b) <= 500:
		a += x
		res += 'A'
	else:
		b += y
		res += 'G'
if abs(a - b) > 500:
	stdout.write('-1\n')
else:
	stdout.write(res + '\n')


import sys
n = int(sys.stdin.readline())
a = 0
g = 0
while n > 0:
	r = sys.stdin.readline().split()
	x = int(r[0])
	y = int(r[1])
	if a + x - g <= 500:
		a += x
		sys.stdout.write('A')
	else:
		g += y
		sys.stdout.write('G')
	n -= 1
sys.stdout.write('\n')


n = int(input())
a = 0
g = 0
ans = []
for i in range(n):
	(x, y) = map(int, input().split())
	if abs(x + a - g) <= 500:
		ans.append('A')
		a += x
	else:
		ans.append('G')
		g += y
if abs(a - g) > 500:
	print(-1)
else:
	print(''.join(ans))


def solve():
	n = int(input())
	distribution = ''
	difference = 0
	for i in range(n):
		(a, g) = [int(price) for price in input().split()]
		if abs(difference + a) <= abs(difference - g):
			difference += a
			distribution += 'A'
		else:
			difference -= g
			distribution += 'G'
	print(distribution)
solve()


sum = 0
s = ''
n = int(input())
for _ in range(n):
	(a, g) = map(int, input().split())
	if sum + a <= 500:
		sum += a
		s += 'A'
	else:
		sum -= g
		s += 'G'
print(s)


from sys import stdin
n = int(stdin.readline())
diff = 0
risp = []
for _ in range(n):
	(x, y) = map(int, stdin.readline().split())
	if abs(diff + x) < 501:
		diff += x
		risp.append('A')
	else:
		diff -= y
		risp.append('G')
if abs(diff) < 501:
	print(''.join(risp))
else:
	print('-1')


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
n = iinput()
A = [0] * n
Sa = Sg = 0
for i in range(n):
	(u, v) = rlinput()
	if abs(Sa + u - Sg) <= 500:
		A[i] = 'A'
		Sa += u
	else:
		A[i] = 'G'
		Sg += v
print(''.join(A))


import sys
n = int(sys.stdin.readline().rstrip())
ansa = 0
ansg = 0
ans = ''
for _ in range(n):
	(a, g) = map(int, sys.stdin.readline().rstrip().split())
	if a + ansa - ansg <= 500:
		print('A', end='')
		ansa += a
	else:
		print('G', end='')
		ansg += g


import sys
s1 = s2 = 0
s = ''
for i in range(int(input())):
	(a, g) = map(int, sys.stdin.readline().split())
	if s1 + a - s2 <= 500:
		s1 += a
		s += 'A'
	else:
		s2 += g
		s += 'G'
print(s)


n = int(input())
s = ''
sa = 0
sb = 0
for i in range(n):
	(p0, p1) = map(int, input().split())
	if abs(sa + p0 - sb) <= 500:
		sa = sa + p0
		s = s + 'A'
	else:
		sb = sb + p1
		s = s + 'G'
print(s)


(sa, sg) = (0, 0)
ans = ''
for _ in range(int(input())):
	(a, g) = map(int, input().split())
	if sa - sg + a <= 500:
		ans += 'A'
		sa += a
	else:
		ans += 'G'
		sg += g
print(ans)


def arr_2d(n):
	return [[float(x) for x in stdin.readline().split()] for i in range(n)]

def get_col(arr, i):
	return [row[i] for row in arr]
from sys import stdin

def main():
	n = int(input())
	a = arr_2d(n)
	(sa, sb, ans) = (0, 0, [])
	for (i, j) in a:
		if abs(sa + i - sb) <= abs(sb + j - sa):
			ans.append('A')
			sa += i
		else:
			ans.append('G')
			sb += j
	print(''.join(ans) if abs(sa - sb) <= 500 else -1)
main()


n = int(input())
x = []
s1 = 0
s2 = 0
s = ''
for i in range(n):
	(a, b) = map(int, input().split())
	if s1 + a - s2 <= 500:
		s1 += a
		s += 'A'
	else:
		s2 += b
		s += 'G'
if max(s1, s2) - min(s1, s2) <= 500:
	print(s)
else:
	print(-1)


import time, math, bisect, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IO():
	return stdin.readline()

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def readTree():
	v = int(input())
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return (adj, v)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * 1000001
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(1000001):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count

def solve():
	n = II()
	li = []
	for i in range(n):
		(a, g) = L()
		li.append([a, g])
	(sa, sg) = (0, 0)
	s = ''
	for i in range(n):
		if abs(sa + li[i][0] - sg) <= 500:
			sa += li[i][0]
			s += 'A'
		elif abs(sg + li[i][1] - sa) <= 500:
			sg += li[i][1]
			s += 'G'
		else:
			print(-1)
			return
	print(s)
solve()


from sys import stdin
n = int(stdin.readline())
a = 0
g = 0
out = ''
while n > 0:
	(r1, r2) = map(int, stdin.readline().split())
	if a + r1 - g <= 500:
		a += r1
		out += 'A'
	else:
		g += r2
		out += 'G'
	n -= 1
print(out)


import sys

def read():
	return map(int, input().split())

def main():
	(n,) = read()
	amount = [0, 0]
	ans = []
	ags = sys.stdin.readlines()
	couples = [tuple(map(int, line.split())) for line in ags]
	it = iter(couples)
	for _ in range(n):
		(a, g) = next(it)
		if abs(amount[0] + a - amount[1]) <= 500:
			amount[0] += a
			ans.append('A')
		else:
			amount[1] += g
			ans.append('G')
	print(''.join(ans) if abs(amount[0] - amount[1]) <= 500 else -1)
main()


n = int(input())
s = ''
A = 0
G = 0
while n > 0:
	n -= 1
	(a, g) = input().split()
	a = int(a)
	g = int(g)
	if A + a - G <= 500:
		s += 'A'
		A += a
	else:
		s += 'G'
		G += g
print(s)


from sys import stdin
n = int(stdin.readline())
a = []
flag = 0
ans = []
sum1 = 0
sum2 = 0
(b, c) = list(map(int, input().split()))
if b <= c:
	sum1 = b
	ans.append('A')
else:
	sum2 = c
	ans.append('G')
for i in range(1, n):
	(b, c) = list(map(int, stdin.readline().split()))
	if b + sum1 - sum2 <= 500:
		sum1 += b
		ans.append('A')
	elif c + sum2 - sum1 <= 500:
		sum2 += c
		ans.append('G')
	else:
		flag = 1
		break
if flag == 0:
	print(''.join(ans))
else:
	print(-1)


n = int(input())
tot = 0
s = ''
while n > 0:
	(a, b) = map(int, input().split())
	if tot + a <= 500:
		tot += a
		s += 'A'
	else:
		tot -= b
		s += 'G'
	n -= 1
print(s)


import sys
input = sys.stdin.readline
read_tuple = lambda _type: map(_type, input().split(' '))

def solve():
	n = int(input())
	prices = [tuple(read_tuple(int)) for _ in range(n)]
	ans = []
	(A, G) = (0, 0)
	for (a, g) in prices:
		if abs(A + a - G) <= 500:
			ans.append('A')
			A += a
		else:
			ans.append('G')
			G += g
	if abs(A - G) <= 500:
		print(''.join(ans))
	else:
		print(-1)
solve()


def solve():
	n = int(input())
	(A, G) = (0, 0)
	res = ''
	for _ in range(n):
		(a, g) = map(int, input().split())
		if abs(A + a - G) <= 500:
			res += 'A'
			A += a
		elif abs(G + g - A) <= 500:
			res += 'G'
			G += g
		else:
			print(-1)
			return
	print(res)
solve()


from sys import stdin
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())
from math import pi
n = it()
su = 0
s = []
for i in range(n):
	(a, g) = mp()
	if su + a <= 500:
		su += a
		s += ['A']
	else:
		su -= g
		s += ['G']
print(''.join(s))


from collections import Counter, defaultdict, deque
import heapq as hq
import itertools
import math
import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	diff = 0
	res = ''
	for i in range(n):
		(a, b) = [int(x) for x in input().split()]
		if abs(diff + a) <= abs(diff - b):
			diff += a
			res += 'A'
		else:
			diff -= b
			res += 'G'
	print(res)
tt = 1
for test in range(tt):
	solve()


from sys import stdin, stdout
ans = ''
x = 0
for i in range(int(stdin.readline())):
	a = int(stdin.readline().split()[0])
	if abs(x - a) > 500:
		x += 1000 - a
		ans += 'G'
	else:
		x -= a
		ans += 'A'
stdout.write(ans)


from sys import stdin, stdout
n = int(stdin.readline())
a = 0
g = 0
ans = ''
for _ in range(n):
	(x, y) = map(int, stdin.readline().split(' '))
	if g + x - a <= 500:
		ans = ans + 'A'
		g = g + x
	else:
		ans = ans + 'G'
		a = a + y
stdout.write(ans)


import sys

def main():
	n = int(sys.stdin.readline())
	a_sum = 0
	b_sum = 0
	while n > 0:
		r = tuple(map(int, sys.stdin.readline().rstrip().split(' ')))
		if a_sum + r[0] <= b_sum + 500:
			sys.stdout.write('A')
			a_sum += r[0]
		else:
			sys.stdout.write('G')
			b_sum += r[1]
		n -= 1
main()


from sys import stdin, stdout
input = stdin.readline
print = stdout.write
n = int(input())
(a, g) = (0, 0)
sol = ''
for i in range(n):
	(prva, druga) = map(int, input().split())
	if a + prva - g <= 500:
		a += prva
		print('A')
	else:
		g += druga
		print('G')


s1 = s2 = 0
s = ''
for i in range(int(input())):
	(a, g) = map(int, input().split())
	if s1 + a - s2 <= 500:
		s1 += a
		s += 'A'
	else:
		s2 += g
		s += 'G'
print(s)


pay1 = 0
pay2 = 0
str = ''
for i in range(int(input())):
	(n, m) = map(int, input().split())
	if n - pay1 + pay2 <= 500:
		pay2 += n
		str += 'A'
	else:
		pay1 += m
		str += 'G'
print(str)


import sys, math, itertools, random, bisect
from collections import defaultdict
INF = sys.maxsize

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
mod = 10 ** 9 + 7
for _ in range(1):
	n = int(input())
	A = 0
	B = 0
	for _ in range(n):
		(x, y) = get_ints()
		if A + x - B <= 500:
			print('A', end='')
			A += x
		else:
			print('G', end='')
			B += y


from collections import Counter, defaultdict, OrderedDict, deque
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from typing import List
import itertools
import sys
import math
import heapq
import string
import random
(MIN, MAX, MOD) = (-1061109567, 1061109567, 1000000007)

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())
n = N()
queries = []
(a, g) = (0, 0)
for _ in range(n):
	(x, y) = RL()
	if g + x - a <= 500:
		g += x
		print('A', end='', sep='')
	else:
		a += y
		print('G', end='', sep='')


a = 0
g = 0
out = ''
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if abs(a + x - g) > 500:
		g += y
		out += 'G'
	else:
		a += x
		out += 'A'
if abs(a - g) > 500:
	print(-1)
else:
	print(out)


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
from itertools import permutations
import heapq
I = sys.stdin.readline
alpha = 'abcdefghijklmnopqrstuvwxyz'
mod = 10 ** 9 + 7

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

def mi():
	return map(int, I().strip().split())

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def isPrime(n):
	if n <= 1:
		return False
	elif n <= 2:
		return True
	else:
		for i in range(2, int(n ** 0.5) + 1):
			if n % i == 0:
				return False
		return True

def main():
	n = ii()
	arr = []
	for i in range(n):
		(a, g) = mi()
		arr.append([a, g])
	ca = 0
	cg = 0
	ans = ''
	for i in arr:
		if abs(i[0] + ca - cg) > 500:
			cg += i[1]
			ans += 'G'
		else:
			ca += i[0]
			ans += 'A'
	print(ans)
main()


n = int(input())
s1 = 0
s2 = 0
ans = ''
for i in range(n):
	(x, y) = map(int, input().split())
	if s1 + x - s2 <= 500:
		ans += 'A'
		s1 += x
	else:
		ans += 'G'
		s2 += y
print(ans)


eggs = int(input())
diff = 0
c = ['A' for i in range(eggs)]
for i in range(eggs):
	a = int(input().split()[0])
	if a + diff < 501:
		diff += a
	else:
		c[i] = 'G'
		diff -= 1000 - a
print(''.join(c))


from __future__ import division, print_function
import math
import os
import sys
from sys import stdin, stdout
from io import BytesIO, IOBase
from itertools import accumulate
from collections import deque
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def regularbracket(t):
	p = 0
	for i in t:
		if i == '(':
			p += 1
		else:
			p -= 1
		if p < 0:
			return False
	else:
		if p > 0:
			return False
		else:
			return True

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def reverse1(string):
	pp = ''
	for i in string[::-1]:
		pp += i
	if pp == string:
		return True
	return False

def reverse2(list1):
	l = []
	for i in list1[::-1]:
		l.append(i)
	if l == list1:
		return True
	return False
import math

def mex(list1):
	p = max(list1) + 1
	for i in range(len(list1)):
		if list1[i] != i:
			p = i
			break
	return p

def main():
	n = int(input())
	aa = 0
	gg = 0
	for _ in range(n):
		(a, g) = map(int, input().split())
		if gg + a - aa <= 500:
			gg += a
			print('A', end='')
		else:
			aa += g
			print('G', end='')
main()


import sys

def get_ints():
	return map(int, I().split())

def get_list():
	return list(map(int, I().split()))

def I():
	return sys.stdin.readline()
t = int(I())
sumA = 0
for k in range(t):
	(a, g) = get_ints()
	if sumA + a <= 500:
		print('A', end='')
		sumA += a
	else:
		print('G', end='')
		sumA -= g


def solve(ps):
	sa = 0
	sg = 0
	sol = []
	for (i, (a, g)) in enumerate(ps):
		if i == 0:
			if a <= 500:
				sol.append('A')
				sa += a
			else:
				sol.append('G')
				sg += g
		elif sa >= sg:
			if sa + a - sg <= 500:
				sol.append('A')
				sa += a
			else:
				sol.append('G')
				sg += g
		elif sg + g - sa <= 500:
			sol.append('G')
			sg += g
		else:
			sol.append('A')
			sa += a
	return ''.join(sol)

def main():
	n = int(input())
	prices = []
	for _ in range(n):
		(a, g) = map(int, input().split())
		prices.append((a, g))
	sol = solve(prices)
	print(sol)
main()


import sys
input = sys.stdin.readline
n = int(input())
sa = 0
sg = 0
ans = []
for _ in range(n):
	(a, b) = map(int, input().split())
	if sa + a - sg <= 500:
		sa += a
		ans.append('A')
	else:
		sg += b
		ans.append('G')
print(''.join(ans))


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
s = []
sv = 0
sg = 0
for i in range(n):
	f = 0
	(a, g) = list(map(int, input().split()))
	if a <= g:
		s.append('A')
		sv += a
		f = 1
	else:
		s.append('G')
		sg += g
	diff = abs(sv - sg)
	if diff > 500:
		if f == 1:
			sv -= a
			sg += g
			_ = s.pop()
			s.append('G')
		else:
			sg -= g
			sv += a
			_ = s.pop()
			s.append('A')
		diff = abs(sv - sg)
if diff > 500:
	print(-1)
print(''.join(s))


from sys import stdin, stdout
inp = stdin.readline
n = int(inp())
a = b = 0
for _ in range(n):
	(x, y) = map(int, inp()[:-1].split())
	if abs(a + x - b) < 501:
		a += x
		stdout.write('A')
	else:
		b += y
		stdout.write('G')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
readint = lambda : int(sys.stdin.readline().rstrip('\r\n'))
readints = lambda : map(int, sys.stdin.readline().rstrip('\r\n').split())
readstr = lambda : sys.stdin.readline().rstrip('\r\n')
readstrs = lambda : map(str, sys.stdin.readline().rstrip('\r\n').split())
readarri = lambda : [int(_) for _ in sys.stdin.readline().rstrip('\r\n').split()]
readarrs = lambda : [str(_) for _ in sys.stdin.readline().rstrip('\r\n').split()]

def solve():
	n = readint()
	fees = [readarri() for _ in range(n)]
	if n == 1:
		if fees[0][0] <= 500:
			print('A')
		elif fees[0][1] <= 500:
			print('G')
		else:
			print(-1)
		return
	(A, G) = (0, 0)
	ans = []
	for i in range(n):
		if i == 0:
			if fees[i][0] <= fees[i][1]:
				A += fees[i][0]
				ans.append('A')
			else:
				G += fees[i][1]
				ans.append('G')
			continue
		if abs(A + fees[i][0] - G) <= 500:
			A += fees[i][0]
			ans.append('A')
		elif abs(G + fees[i][1] - A) <= 500:
			G += fees[i][1]
			ans.append('G')
		else:
			print(-1)
			return
	if abs(A - G) > 500:
		print(-1)
		return
	print(''.join(ans))

def main():
	t = 1
	for _ in range(t):
		solve()
main()


from sys import stdin
n = int(stdin.readline())
sa = 0
sg = 0
ans = []
for i in range(n):
	(a, g) = map(int, stdin.readline().split())
	if abs(sa + a - sg) <= abs(sa - (sg + g)):
		sa = sa + a
		ans.append('A')
	else:
		sg = sg + g
		ans.append('G')
if abs(sa - sg) <= 500:
	print(''.join(ans))
else:
	print('-1')


n = int(input())
a = 0
ans = ''
for _ in range(n):
	(x, y) = map(int, input().split())
	if a + x <= 500:
		a += x
		ans += 'A'
	else:
		a -= y
		ans += 'G'
print(ans)