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

namespace ConsoleApp2
{
    internal class Program
    {
        static long xor_djelilaca(long n)
        {
            long rezultat = 1;
            long[] a = djelioci(n);
            for (int i = 1; i < a.Length; i++)
            {
                rezultat ^= a[i];
            }
            return rezultat;
        }

        static long[] djelioci(long n)
        {
            List<long> list = new List<long>();
            for (long j = 1; j * j <= n; j++)
            {
                if (n % j == 0)
                {
                    list.Add(j);
                    if (n / j != j)
                        list.Add(n / j);
                }
            }
            return list.ToArray();
        }

        static void Main(string[] args)
        {
            long[] p1 = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long[] p2 = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            foreach (var x in p2)
            {
                Console.Write($"{xor_djelilaca(x)} ");
            }
        }
    }
}