#include <stdio.h>
#include <string.h>
//只需要考虑余数的大数除法
int main() {
    char arr[30];
    while (scanf("%s", arr) != EOF) {
        char end[] = "-1";
        if (strcmp(arr, end) == 0){
            printf("none\n");
            break;
        }
        int len = strlen(arr);
        int tag = 0;
        for (int i=2;i<10;i++){
            int yushu=0;
            for (int j=0;j<len;j++){
                int num = arr[j]-'0'+yushu*10;
                yushu = num%i;
            }
            if(yushu == 0){
                if (tag){
                    printf(" %d",i);
                }else {
                    printf("%d",i);
                    tag = 1;
                }
            }
        }
        if (tag){
            printf("\n");
        }else {
            printf("none\n");
        }
    }
    return 0;
}