#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int s;
  while (cin >> n) {
    if (n == -1) break;
    for (int i = 0; i < n; i++) {
      cin >> s;
      if (s == 0)
        cout << "0111111" << endl;
      else if (s == 1)
        cout << "0000110" << endl;
      else if (s == 2)
        cout << "1011011" << endl;
      else if (s == 3)
        cout << "1001111" << endl;
      else if (s == 4)
        cout << "1100110" << endl;
      else if (s == 5)
        cout << "1011101" << endl;
      else if (s == 6)
        cout << "1111101" << endl;
      else if (s == 7)
        cout << "0100111" << endl;
      else if (s == 8)
        cout << "1111111" << endl;
      else if (s == 9)
        cout << "1101111" << endl;
    }
  }
  return 0;
}
