/* Problem   Code
 * Algorithm Euler Tour (Depth First Search)
 * Runtime   O(10^n)
 * Author    Mark Dettinger
 * Date      2004.09.08
 */

#include <assert.h>
#include <stdio.h>

int edge[1000000][10]; /* edge[u][v] = 1  ===  edge from u to v has not been used */
int state[10000001];   /* state[i] = state after the i-th key press */
char seq[10000001];    /* the digit sequence */

void find_sequence (int n)
{
  int num_states, i, q, head, tail;

  /* There are 10^(n-1) states. */
  num_states = 1;
  for (i=1 ; i<n ; i++)
    num_states *= 10;
  /* From every state, by pressing a key, one of 10 states is reachable. */
  for (q=0 ; q<num_states ; q++)
    for (i=0 ; i<10 ; i++)
      edge[q][i] = 1;
  /* We always start with pressing the 0 key n-1 times. This puts us in state 0. */
  for (i=1 ; i<n ; i++)
    printf("0");
  /* Produce an Euler tour */
  head = 0;
  tail = num_states*10;
  state[head] = 0;
  seq[tail] = 0;
  while (head!=tail) {
    q = state[head];
    /* We are in state q and look for a key i to press. */
    for (i=0 ; i<10 ; i++)
      if (edge[q][i]) break;
    if (i<10) {
      /* forward edge found: press the key i and move on */
      seq[head++] = '0' + i;
      edge[q][i] = 0;
      state[head] = (q * 10 + i) % num_states;
    } else {
      /* no forward edge left: all keys have already been pressed -> go back */
      state[tail] = state[head];
      seq[--tail] = seq[--head];
    }
  }
  /* Output the Euler tour */
  printf("%s\n", seq);
}

int main()
{
  int n;
  FILE *in = stdin;
  assert (in!=NULL);
  while (1)
  {
    fscanf(in, " %d ", &n);
    if (n == 0) break;
    assert (1 <= n && n <= 6);
    find_sequence(n);
  }
  return 0;
}
