#include <stdio.h>//字符串因子不会 原来也和进位有关 学到了
#include <string.h>
#define N 31

int main()
{
    char str[N];
    int c[N];
    int mod;
    int count;
    while(gets(str))
    {
        if(str[0]=='-') break;
        int len=strlen(str);
        for(int i=0; i<len; i++)//高位在前
        {
            c[i]=str[i]-'0';
        }
        count=0;
        for(int k=2; k<=9; k++)
        {
            mod=0;
            for(int i=0; i<len; i++)
            {
                mod=(mod*10+c[i])%k;
            }
            if(mod==0)
            {
                if(count>0) printf(" ");
                printf("%d", k);
                count++;
            }
        }
        if(count==0) printf("none");
        printf("\n");
    }
    return 0;
}