#include <iostream>
#include <cassert>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>

using namespace std;

#define file cin

int visited[1000000];
int states[1000000];
string seq[1000000];
string tmp;
int m;
int n;
int s;

int solve( int i ) {
	assert( i >= 0 && i < m/10 );
	if( states[i] ) {
		tmp = "";
		return i;
	}
	states[i] = true;

	for( int k = 0;k < 10; k++ ) {
		if( !visited[i*10+k] ) {
			visited[i*10+k] = true;
			int cycle = solve( (i*10+k) % (m/10) );
			if( cycle == i ) {
				tmp.push_back( '0' + k );
				s++;
				reverse( tmp.begin(), tmp.end() );
				s-= tmp.size();
				//				if( s < 0 ) cout << i << " "<< tmp << endl;
				s = 0;
				seq[i] += tmp;
				tmp = "";
			}
			else {
				states[i] = false;
				s++;
				tmp.push_back( '0'+k );
				return cycle;
			}
		}
		if( tmp != "" )
			cout << "NOT EMPTY " << tmp << endl;
	}
	states[i] = false;
	return -1;
}

void print( int i ) {
	//	cout << "ERROR " << tmp.substr( tmp.size()-n+1 ) << " " << i << endl;
	//if( atoi( tmp.substr( tmp.size()-n+1 ).c_str() ) != i )
	if( states[i] ) return;
	states[i] = true;
	int k = i;
	for( int j =0 ; j < seq[i].size(); j++ ) {
		//tmp += seq[i][j];
		cout << seq[i][j];
		k = ( k*10+seq[i][j]-'0' ) % (m/10);
		print( k );
	}
	seq[i] = "";
}

int main() {
	//ifstream file( "code.in" );
	while( cin >> n ) {
		if( n == 0 ) break;
		m = 1;
		s = 0;
		for( int i = 0; i < n; i++ ) m *= 10;
		for( int i = 0; i < m; i++ ) visited[i] = 0;
		for( int i = 0; i < m/10; i++ ) {
			states[i] = 0;
			seq[i] = "";
		}
		//visited[0] = 1;
		for( int i = 0; i < m/10; i++ ) {
			solve( i );
			//			for( int j = 0; j < m/10; j++ )
			//				if( states[j] ) cout << "NOT CLEARED" << endl;
			if( tmp != "" ) cout << "S" << endl;
			tmp = "";
		}
		
		for( int i = 0; i < m; i++ )
			if( !visited[i] )
				cout << "NOT VISITED " <<i << endl;
		
		for( int i = 1; i < n; i++ ) cout << '0';
		
		int sum = 0;
		for( int i = 0; i < m/10; i++ ) {
			if( states[i] ) cout << "NOT CLEARED" << endl;
			sum += seq[i].size();
		}
			
		print( 0 );
		cout << endl;
		//		cout << tmp.size() << " " << sum << " " << s << " "<< m + n - 1 << endl;
		//		cout << tmp << endl;
		
		// test
		/*		for( int i = 0; i < m; i++ ) {
			string s;
			int j = i;
			for( int k = 0; k < n; k++ ) {
				s += '0' + (j % 10);
				j/=10;
			}
			int p = tmp.find( s );
			if( p >= tmp.size() || p < 0 )
				cout << "ERROR " << s << endl;
				}*/
	}
	return 0;
}
