#include <iostream>
#include <cstring>
using namespace std;
const int maxn=100;
struct lnum{
    int digit[maxn];
    int length;
    lnum();
    lnum(int x);
    lnum(string x);
    bool operator<=( lnum &b);
    lnum operator%( lnum &b);
    lnum operator-( lnum &b);
    bool operator==(lnum &b);
};
lnum::lnum(string x){
    length=0;
    memset(digit,0,sizeof(digit));
    for(int i=x.length()-1;i>=0;i--){
        digit[length++]=x[i]-'0';
    }
}
bool lnum::operator==(lnum &b){
    if(length!=b.length) return false;
    int i=length-1;
    while(digit[i]==b.digit[i] && i>0) i--;
    return digit[i]==b.digit[i];
}
lnum::lnum(int x){
    length=0;
    memset(digit,0,sizeof(digit));
    while(x>0){
        digit[length++]=x%10;
        x/=10;
    }
}
lnum lnum::operator-(lnum &b){
    lnum answer;
    int carry=0;
    for(int i=0;i<length;i++){
        int cu=digit[i]-b.digit[i]-carry;
        if(cu<0){
            carry=1;
            cu+=10;
        }
        answer.digit[i]=cu;
        answer.length++;
    }
    while(answer.digit[answer.length-1]==0 && answer.length>1) answer.length--;
    return answer;
}
lnum::lnum(){
    length=0;
    memset(digit,0,sizeof(digit));
}
bool lnum::operator<=( lnum &b){
    if(length<b.length) return true;
    else if(length>b.length) return false;
    else {
        int i=length-1;
        while(digit[i]==b.digit[i] && i>0) i--;
        return digit[i]<=b.digit[i];
    }
}
lnum lnum::operator%( lnum &b){
    lnum rem;
    for(int i=length-1;i>=0;i--){
        if(!(rem.length==1 && rem.digit[0]==0)){
            for(int j=rem.length-1;j>=0;j--){
                rem.digit[j+1]=rem.digit[j];
            }
            rem.length++;
        }
        rem.digit[0]=digit[i];
        while(b<=rem){
            rem=rem-b;
        }
    }
    return rem;
}
void outp(lnum x){
	for(int i=x.length-1;i>=0;i--) cout<<x.digit [i];
	cout<<endl;
}

int main() {
    string n;
    while(cin>>n){
        if(n.length()==2 && (n=="-1")) {
        continue;}
        lnum c(n);
        int flag=0;
        for(int i=2;i<10;i++){
            lnum k(i);
            lnum kk=c%k;
            if(kk.length==1 && kk.digit[0]==0) {cout<<i<<' ';
            flag=1;}
        }
        if(flag==0) cout<<"none"<<endl;
        else cout<<endl;
    }
}