#include <iostream>
#include<vector>
#include<string>
using namespace std;
//高精度
vector<int> div(vector<int>a, int b, int& r) {
    int t = 0;
    vector<int>c;
    //就除法要倒着来
    for (int i = a.size() - 1; i >= 0; i--) {
        int tmp = (t * 10 + a[i]) / b;
        c.push_back(tmp);
        t = (t * 10 + a[i]) % b;
    }
    r = t;
    return c;
}
int res[15];
int main() {
    string str;
    while (cin >> str) {
        if (str == "-1")break;
        int count = 0;
        vector<int>a;
        //先把字符串倒过来读
        for (int i = str.size() - 1; i >= 0; i--) {
            a.push_back(str[i] - '0');
        }
        for (int k = 2; k <= 9; k++) {
            int r = -1;
            div(a, k, r);
            if (r == 0) {
                res[count++] = k;
            }
        }
        if (count == 0)cout << "none" << endl;
        else {
            for (int i = 0; i < count - 1; i++) {
                cout << res[i] << ' ';
            }
            cout << res[count - 1] << endl;
        }
    }
}
// 64 位输出请用 printf("%lld")