//字符串除法模拟
#include <iostream>
#include <string>
using namespace std;

bool canModk(string s, int k){
    int current = 0;
    for(string::size_type i = 0; i < s.size(); i++){
        current = current * 10 + s[i] - '0';
        if(current >= k){
            s[i] = current / k + '0';
            current %= k;
        }
        else s[i] = '0';
    }
    if(current == 0) return true;
    else return false;
}

int main() {
    string s;
    while(getline(cin ,s)){
        if(s == "-1") break;
        else{
            bool first = true;
            for(int k = 2; k <= 9; k++){
                if(canModk(s, k)){
                    if(first) cout << k;
                    else cout << ' ' << k;
                    first = false;
                }
            }
            if(first) cout << "none";
            cout << endl;
        }
    }
    return 0;
}
// 64 位输出请用 printf("%lld")