#include <cstdio> #include <iostream> #include <vector> using namespace std; const int MAX=10001; vector <int> prime; bool isPrime[MAX]; void Initial(){ for(int i=0;i<MAX;i++){ isPrime[i]=true; } isPrime[0]= false; isPrime[1]= false; for(int i=2;i<MAX;i++){ if(!isPrime[i]){ continue; } prime.push_back(i); for(int j=i*i;j<MAX;j+=i){ isPrime[j]= false; } } return; } int main(){ Initial(); int n; while(scanf("%d",&n)!=EOF){ if(n==0){ break; } bool isOutput=false; for(int i=0;i<prime.size()&&prime[i]<n; i++){ if(prime[i]%10==1){ isOutput= true; printf("%d ",prime[i]); } } if(!isOutput){ printf("-1"); } printf("\n"); } return 0; }