#include <iostream>
using namespace std;
int main()
{
int number;
cin>>number;
int i;
for (i = 10000; i < 100000; i++) {
int a=i/10000;
int b=i%10000/1000;
int c=i%10000%1000/100;
int d=i%10000%1000%100/10;
int e=i%10000%1000%100%10;
if(a==e && b==d && a+b+c+d+e==number){
cout<<i<<endl;
}
}
for (i = 100000; i < 1000000; i++) {
int a=i/100000;
int b=i%100000/10000;
int c=i%100000%10000/1000;
int d=i%100000%10000%1000/100;
int e=i%100000%10000%1000%100/10;
int f=i%100000%10000%1000%100%10;
if(a==f && b==e && c==d && a+b+c+d+e+f==number){
cout<<i<<endl;
}
}
return 0;
}