#include using namespace std; int main() { int N; cin >> N; int ans = 0; if( N == 1 ) ans = 1491; else if( N == 2 ) { int od[9] = { 0, 2, 3, 4, 5, 6, 7, 8, 9 }; vector a( od, od + 9 ); do { if( a[4] == 0 || a[5] == 0 ) continue; int b = a[4] * 1000 + a[4] * 100 + a[1] * 10 + a[2]; int c = a[5] * 1000 + a[6] * 100 + a[7] * 10 + a[8]; int d = 10000 + a[0] * 1000 + a[1] * 100 + a[2] * 10 + a[3]; if( b + c == d ) { ans = d; break; } } while( next_permutation( a.begin(), a.end() ) ); } else { int od[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; vector a( od, od + 10 ); do { if( a[3] == 0 || a[6] == 0 || a[9] == 0 ) continue; int b = a[3] * 100000 + a[9] * 10000 + a[4] * 1000 + a[0] * 100 + a[2] * 10 + a[5]; int c = a[6] * 10000 + a[0] * 1000 + a[5] * 100 + a[7] * 10 + a[8]; int d = a[9] * 100000 + a[0] * 10000 + a[1] * 1000 + a[2] * 100 + a[0] * 10 + a[1]; if( b + c == d ) { ans = d; break; } } while( next_permutation( a.begin(), a.end() ) ); } cout << ans << endl; }