import java.io.*;

public class code_axel_2
{
    public static void main(String[] args)
        throws Exception
    {
        StreamTokenizer in = new StreamTokenizer(new InputStreamReader(System.in));
        while (in.nextToken() == StreamTokenizer.TT_NUMBER) {
            int n = (int) in.nval;
            if (n == 0)
                break;

            int m = 1;
            for (int i = 0; i < n; ++i)
                m *= 10;

            boolean[] o = new boolean[m];
            StringBuffer t = new StringBuffer(m + n - 1);
            StringBuffer u = new StringBuffer(m + n - 1);
            for (int i = 0; i < n; ++i)
                u.append('0');

            int s = 0;
            int r = 0;
            int i = 0;
            int j = n;
            int a;
            for (int z = 1; z < m; ++z) {
                o[s] = true;
                s = (s * 10) % m;
                a = 0;
                while (a < 10 && o[s + a])
                    ++a;
                if (a > 9) {
                    t.insert(i, u);
                    u.setLength(0);

                    while (true) {
                        a = 0;
                        while (a < 10 && o[r + a])
                            ++a;
                        if (a < 10)
                            break;
                        r = ((r + t.charAt(j) - '0') * 10) % m;
                        ++j;
                    }
                    s = r;
                    i = j;

                }
                u.append(a);
                s += a;
            }
            t.insert(i, u);
            System.out.println(t);
        }
    }
}
