#include
#include
using namespace std;
int main() {
int N;//N是位数
cin >> N;
for (int tot = pow(10, N - 1); tot < pow(10, N); tot++) {
while (tot != 0) {
int sum = 0;
int temp;
temp = tot % 10;
tot = tot / 10;
int squ = pow(temp, N);
sum += squ;
}
if (sum == tot) {
cout << tot << endl;
}
}
}
return 0;
}