import java.util.Scanner;
//水仙花数是指一个N位正整数(7≥N≥3),它的每个位上的数字的N次幂之和等于它本身。例如:153=13+53+33。 要求编写程序,计算所有N位水仙花数。
public class Test {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
double x;
double temp = 0;
for (double i = Math.pow(10,N-1); i < Math.pow(10,N)-1 ; i++) {
double sum = 0;
temp = i;
for (int j = 0; j < N; j++) {
x = (int)i%10;
sum = (int)sum + (int)Math.pow(x,N);
i = (int)i/10;
}
if ((int)sum==(int)temp){
System.out.println((int)temp);
}
}
}
}