#include <bits/stdc++.h>
void out(int s) {
  int i;
  for (i = 6; i >= 0; i--) {
    printf("%d", s >> i & 1);
  }
  printf("\n");
}
int main() {
  int p[10] = {077, 06, 0133, 0117, 0146, 0155, 0175, 0147, 0177, 0157};
  int n, s, a;
  while (scanf("%d", &n) == 1 && n != -1) {
    s = 0;
    while (n--) {
      scanf("%d", &a);
      out(s ^ p[a]);
      s = p[a];
    }
  }
}
