#include <bits/stdc++.h>
int s[10] = {63, 6, 91, 79, 102, 109, 125, 39, 127, 111}, d = 0, n, b = 0, i;
int main() {
  for (; d || (b = 0, scanf("%d", &d), d != -1); d--) {
    scanf("%d", &n);
    for (i = 64, b ^= s[n]; i >= 1; i /= 2) printf("%d", (b & i) / i);
    b = s[n];
    puts("");
  }
}
