using System;

public class Hello
{
    public static void Main()
    {
        var a = new int[] { 63, 6, 91, 79, 102, 109, 125, 7, 127, 111 };
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == -1) break;
            var pre = int.Parse(Console.ReadLine().Trim());
            Console.WriteLine(getAns(Convert.ToString(0 ^ a[pre], 2)));
            for (int i = 1; i < n; i++)
            {
                var d = int.Parse(Console.ReadLine().Trim());
                var ret = Convert.ToString(a[pre] ^ a[d], 2);
                Console.WriteLine(getAns(ret));
                pre = d;
            }
        }
    }
    public static string getAns(string a)
    {
        return new string('0', 7 - a.Length) + a;
    }
}

