Problem: 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 ≤ 106) — the number of eggs.

Next n lines contain two integers ai and gi each (0 ≤ ai, gi ≤ 1000; ai + gi = 1000): ai is the price said by A. for the i-th egg and gi 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 Sa, and the money Uncle J. must pay G. for the painting as Sg, then this inequality must hold: |Sa - Sg| ≤ 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

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;

public class Main {
	
	
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int[] A = new int[n]; int[] G = new int[n];
        for(int i = 0; i < n; i++) {
        	A[i] = sc.nextInt(); G[i] = sc.nextInt();
        }
        int a = 0, g = 0;
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++) {
        	int tmpA = a + A[i]; int tmpG = g + G[i];
        	if(Math.abs(tmpA - g) <= 500) {
        		a = tmpA;
        		sb.append('A');
        	}
        	else {
        		g = tmpG;
        		sb.append('G');
        	}
        }
        pw.print(sb);
       
        
        pw.close();
    }

    public static long mod(long a, long b){
        long m = a % b;
        if(m < 0) m += Math.abs(b);
        return m; 
    }
    public static void sort(int[] arr){
        ArrayList<Integer> l = new ArrayList<>();
        for(int i : arr) l.add(i);
        Collections.sort(l);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = l.get(i);
        }
    }
    public static long C(int n, int k){
        double res = 1;
        for (int i = 1; i <= k; i++) {
            res *= (double) (n - k + i) / i;
        }
        return (long) (res + 0.01);
    }

    static class Pair{
        int x, y;
        public Pair(int x, int y){
            this.x = x;
            this.y = y;
        }

        public String toString() {
            return "(" + x + "," + y + ")";
        }
    }
    static class SegmentTree{		// 1-based DS, OOP
        int N; 			//the number of elements in the array as a power of 2 (i.e. after padding)
        int[] array, sTree, lazy;

        SegmentTree(int[] in)
        {
            array = in; N = in.length - 1;
            sTree = new int[N<<1];		//no. of nodes = 2*N - 1, we add one to cross out index zero
            lazy = new int[N<<1];
            build(1,1,N);
        }

        void build(int node, int b, int e)	// O(n)
        {
            if(b == e)
                sTree[node] = array[b];
            else
            {
                int mid = b + e >> 1;
                build(node<<1,b,mid);
                build(node<<1|1,mid+1,e);
                sTree[node] = sTree[node<<1]+sTree[node<<1|1];
            }
        }


        void update_point(int index, int val)			// O(log n)
        {
            index += N - 1;
            sTree[index] += val;
            while(index>1)
            {
                index >>= 1;
                sTree[index] = sTree[index<<1] + sTree[index<<1|1];
            }
        }


        void update_range(int i, int j, int val)		// O(log n)
        {
            update_range(1,1,N,i,j,val);
        }

        void update_range(int node, int b, int e, int i, int j, int val)
        {
            if(i > e || j < b)
                return;
            if(b >= i && e <= j)
            {
                sTree[node] += (e-b+1)*val;
                lazy[node] += val;
            }
            else
            {
                int mid = b + e >> 1;
                propagate(node, b, mid, e);
                update_range(node<<1,b,mid,i,j,val);
                update_range(node<<1|1,mid+1,e,i,j,val);
                sTree[node] = sTree[node<<1] + sTree[node<<1|1];
            }

        }
        void propagate(int node, int b, int mid, int e)
        {
            lazy[node<<1] += lazy[node];
            lazy[node<<1|1] += lazy[node];
            sTree[node<<1] += (mid-b+1)*lazy[node];
            sTree[node<<1|1] += (e-mid)*lazy[node];
            lazy[node] = 0;
        }

        int query(int i, int j)
        {
            return query(1,1,N,i,j);
        }

        int query(int node, int b, int e, int i, int j)	// O(log n)
        {
            if(i>e || j <b)
                return 0;
            if(b>= i && e <= j)
                return sTree[node];
            int mid = b + e >> 1;
            propagate(node, b, mid, e);
            int q1 = query(node<<1,b,mid,i,j);
            int q2 = query(node<<1|1,mid+1,e,i,j);
            return q1 + q2;

        }
    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

        public int[] nextIntArr(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = Integer.parseInt(next());
            }
            return arr;
        }

        public long[] nextLongArr(int n) throws IOException {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = Integer.parseInt(next());
            }
            return arr;
        }

    }
}