#include <iostream>
#include <string>
#include <cmath>
using namespace std;

bool check(string num, int len) {
    int sum = 0;

    for (int i = 0; i < len; i++) {
        sum += (int) round(
            pow((int) (num[i] - '0'), len)
        );
    }
    
    if (sum == stoi(num)) {
        return true;
    }

    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    for (int i = 153; i < 1000; i++) {
        if (check(to_string(i), 3)) {
            cout << to_string(i) << "\n";
        }
    }
    for (int i = 1000; i < 10000; i++) {
        if (check(to_string(i), 4)) {
            cout << to_string(i) << "\n";
        }
    }
    for (int i = 10000; i < 100000; i++) {
        if (check(to_string(i), 5)) {
            cout << to_string(i) << "\n";
        }
    }

    return 0;
}