using System;

namespace AOJ.Volume2
{
    public class SevenSegments
    {
        public static int Main()
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n < 0) { break; }

                for (int i = 0; i < n; i++)
                {
                    int input = int.Parse(Console.ReadLine());
                    string output;
                    switch (input)
                    {
                        case 0: { output = "0111111"; break; }
                        case 1: { output = "0000110"; break; }
                        case 2: { output = "1011011"; break; }
                        case 3: { output = "1001111"; break; }
                        case 4: { output = "1100110"; break; }
                        case 5: { output = "1101101"; break; }
                        case 6: { output = "1111101"; break; }
                        case 7: { output = "0100111"; break; }
                        case 8: { output = "1111111"; break; }
                        case 9: { output = "1101111"; break; }
                        default: { output = ""; break; }
                    }
                    Console.WriteLine(output);
                }
            }
            return 0;
        }
    }
}