#include <bits/stdc++.h>
int signal(int *da, int set) {
  if (set == 1) {
    if (*da == 0) {
      *da = 1;
      return 1;
    } else {
      *da = 1;
      return 0;
    }
  } else {
    if (*da == 0) {
      *da = 0;
      return 0;
    } else {
      *da = 0;
      return 1;
    }
  }
}
class seg {
 public:
  int a, b, c, d, e, f, g;
  int da, db, dc, dd, de, df, dg;
  void empty();
  void set(int num);
  void Set(int num);
};
void seg::empty() {
  a = b = c = d = e = f = g = 0;
  da = a;
  db = b;
  dc = c;
  dd = d;
  de = e;
  df = f;
  dg = g;
}
void seg::set(int num) {
  switch (num) {
    case 0:
      a = signal(&da, 1);
      b = signal(&db, 1);
      c = signal(&dc, 1);
      d = signal(&dd, 1);
      e = signal(&de, 1);
      f = signal(&df, 1);
      g = signal(&dg, 0);
      break;
    case 1:
      a = signal(&da, 0);
      b = signal(&db, 1);
      c = signal(&dc, 1);
      d = signal(&dd, 0);
      e = signal(&de, 0);
      f = signal(&df, 0);
      g = signal(&dg, 0);
      break;
    case 2:
      a = signal(&da, 1);
      b = signal(&db, 1);
      c = signal(&dc, 0);
      d = signal(&dd, 1);
      e = signal(&de, 1);
      f = signal(&df, 0);
      g = signal(&dg, 1);
      break;
    case 3:
      a = signal(&da, 1);
      b = signal(&db, 1);
      c = signal(&dc, 1);
      d = signal(&dd, 1);
      e = signal(&de, 0);
      f = signal(&df, 0);
      g = signal(&dg, 1);
      break;
    case 4:
      a = signal(&da, 0);
      b = signal(&db, 1);
      c = signal(&dc, 1);
      d = signal(&dd, 0);
      e = signal(&de, 0);
      f = signal(&df, 1);
      g = signal(&dg, 1);
      break;
    case 5:
      a = signal(&da, 1);
      b = signal(&db, 0);
      c = signal(&dc, 1);
      d = signal(&dd, 1);
      e = signal(&de, 0);
      f = signal(&df, 1);
      g = signal(&dg, 1);
      break;
    case 6:
      a = signal(&da, 1);
      b = signal(&db, 0);
      c = signal(&dc, 1);
      d = signal(&dd, 1);
      e = signal(&de, 1);
      f = signal(&df, 1);
      g = signal(&dg, 1);
      break;
    case 7:
      a = signal(&da, 1);
      b = signal(&db, 1);
      c = signal(&dc, 1);
      d = signal(&dd, 0);
      e = signal(&de, 0);
      f = signal(&df, 1);
      g = signal(&dg, 0);
      break;
    case 8:
      a = signal(&da, 1);
      b = signal(&db, 1);
      c = signal(&dc, 1);
      d = signal(&dd, 1);
      e = signal(&de, 1);
      f = signal(&df, 1);
      g = signal(&dg, 1);
      break;
    case 9:
      a = signal(&da, 1);
      b = signal(&db, 1);
      c = signal(&dc, 1);
      d = signal(&dd, 1);
      e = signal(&de, 0);
      f = signal(&df, 1);
      g = signal(&dg, 1);
      break;
  }
  printf("%d%d%d%d%d%d%d\n", g, f, e, d, c, b, a);
  printf("%d%d%d%d%d%d%d\n", dg, df, de, dd, dc, db, da);
}
int main() {
  int num, n;
  seg seg;
  seg.empty();
  scanf("%d", &n);
  while (n != -1) {
    while (n--) {
      scanf("%d", &num);
      seg.set(num);
    }
    seg.empty();
    scanf("%d", &n);
  }
  return 0;
}
