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