namespace ConsoleApp3
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string[] unos = Console.ReadLine().Split();
            int n = Convert.ToInt32(unos[0]);
            int k = Convert.ToInt32(unos[1]);
            string[] delioci = Console.ReadLine().Split();
            int[] d= new int[k];
            int[] x=new int[k];
            for (int i = 0; i < k; i++)
            {
                d[i] = Convert.ToInt32(delioci[i]);
            }
            for (int i = 0; i < k; i++)
            {
                for (int j = 1; j < Math.Sqrt(d[i]); i++)
                {
                    if (d[i] % j == 0)
                        x[i] = 1 ^ x[i];
                }
            }
            foreach (int br in x)
            {
                Console.Write(br+" ");
            }

        }
    }
}