namespace Tak3
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            long n = long.Parse(s[0]); int k = int.Parse(s[1]);
            string[] s1 = Console.ReadLine().Split();
            List<long> del = new List<long>();
            List<long> del2 = new List<long>();
            /*
            foreach (string t in s1)
            {
                del.Add(long.Parse(t)); del2.Add(long.Parse(t));
            }
            */
            del2.Sort();
            for (int i = 0; i < k; i++)
            {
                long xorington = 0;
                /*
                for (int j = 0; j < k; j++)
                {
                    if (del[i] % del2[j] == 0)
                    {
                        xorington = xorington ^ del2[j];
                    }
                    else if (del[i] < del2[j]) break;
                }
                */
                if (i == k - 1)
                    Console.Write(xorington);
                else Console.Write(xorington + " ");
            }
        }
    }
}