#include <bits/stdc++.h>
#define MAX 31
using namespace std;
//typedef long long ll;

int main(){
	string s;
	int data[MAX],res[MAX],len;
	vector<int> ans;
	while(cin>>s){
		if(s == "-1")
			return 0;
		memset(data,0,sizeof(data));
		memset(res,0,sizeof(res));
		len = s.size();
		for(int i = 0; i < len; i++)
			data[i] = s[i] - '0';
		
		for(int k = 2; k <= 9; k++){	
			int tmp = data[0];
			for(int i = 0; i < len; i++){
				if(tmp < k){
					tmp = tmp * 10 + data[i+1];
					res[i] = 0;	//可略 
				}else{
					tmp %= k;	//余数 
					res[i] = tmp / k; 
					tmp = tmp * 10 + data[i+1];
				}
			}
			if(tmp == 0)
				ans.push_back(k);
		}
		if(ans.empty())
			cout<<"none";
		else{
			for(int i = 0; i < ans.size(); i++)
				cout<<ans[i]<<" ";
		}
		cout<<endl;
		ans.clear();
	}
}