#include <stdio.h>
int main () {
//JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。
int n;
int d;
scanf("%d", &n);
int i = 1;
int first = 1;
while ( i<n ){
first *= 10;
i++;
}
printf("first=%d\n", first);
i = first;
while ( i < first*10 ){
int t = i;
int sum = 0;
do {
d=t%10;
t/=10;
int p = d;
int j = 1;
while ( j < n ){
p*=d;
j++;
}
sum += p;
} while ( t>0 );
if( sum == i ){
printf("%d\n", i);
}
i++;
}
return 0;
}