#include <bits/stdc++.h>
int main(void) {
  int len, i, num;
  while (scanf("%d", &len) != EOF && len != -1) {
    for (i = 0; i < len; i++) {
      scanf("%d", &num);
      switch (num) {
        case 0:
          printf("0111111\n");
          break;
        case 1:
          printf("0000110\n");
          break;
        case 2:
          printf("1011011\n");
          break;
        case 3:
          printf("1001111\n");
          break;
        case 4:
          printf("1100110\n");
          break;
        case 5:
          printf("1101101\n");
          break;
        case 6:
          printf("1111101\n");
          break;
        case 7:
          printf("0100111\n");
          break;
        case 8:
          printf("1111111\n");
          break;
        case 9:
          printf("1101111\n");
          break;
      }
    }
  }
  return 0;
}
