using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Nocna_voznja
{
    class Program
    {
        struct rastojanje
        {
            public int u, v;
        }

        struct Dogadjaji
        {
            public string  a;
        }
        static void Zameni(ref int a, ref int b)
        {
            int p = a;
            a = b;
            b = p;
        }
        /*static int[] Ispuni(Dogadjaji[] d, rastojanje[] r, int n, int q)
        {
            int[] ispunjeno = new int[q];
            for (int i = 0; i < q; i++)
            {
                //string s = d[i].a[i].ToString();
                if (d[i].a[0]==1)
                {
                    Zameni(ref d[i].a[1], ref d[i].a[2]);
                    ispunjeno[i] = d[i].a[i];

                }
                else if (d[i].a[0]==2)
                {
                    
                }
            }
            return ispunjeno;
        }*/
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            if (N <= 1 || N >= 80000)
            {
                Console.WriteLine("G");
                N = int.Parse(Console.ReadLine());
            }

            int[] a = new int[N];
            string[] s = Console.ReadLine().Split();

            for (int i = 0; i < N; i++)
            {
                a[i] = int.Parse(s[i]);
                //ogranicenje
            }


            rastojanje[] r = new rastojanje[N - 1];

            for (int i = 0; i < N - 1; i++)
            {
                string[] e = Console.ReadLine().Split();
                r[i].u = int.Parse(s[0]);
                r[i].v = int.Parse(s[1]);
            }

            int Q = int.Parse(Console.ReadLine());
            Dogadjaji[] d = new Dogadjaji[Q];

            for (int i = 0; i < Q; i++)
            {
                Console.WriteLine("K");
                string[] e = Console.ReadLine().Split();
                d[i].a = e[i];

            }
            


            Console.ReadKey();
        }
    }
}