#include<iostream> #include<cmath> #include<cstring> #include<cstdio> #include<algorithm> #include<ctime> #define ll long long using namespace std; const int maxn = 1000005; int data[maxn],data2[maxn]; bool flag[maxn]; int init(int n){ memset(flag,1,sizeof(flag)); int i,j,k=0; int s,e = 1001; for(i=10;i<n;i+=5)flag[i] = 0; for(i=9;i<e;i+=4){ if(flag[i]){ data[k++] = i; for(s=i*2,j=i*i;j<n;j+=s)flag[j] = 0; } } for(;i<n;i+=4)if(flag[i])data[k++] = i; return k; } int isprime(int n){ if(n%4!=1)return false; for(int i=5;i<=sqrt(1.0*n);i+=4){ int t = n/i; if((n==t*i)&&(t%4==1)&&(flag[t]==1)&&(flag[i]==1)){ return true; } } return false; } int main(){ int k = init(maxn-1); int n,i,p=0; for(i=25;i<=maxn-4;i++){ if(isprime(i)){ data2[p++] = i; } } while(scanf("%d",&n)==1&&n){ for(i=0;i<p;i++) if(data2[i]>n){ break; } printf("%d %d\n",n,i); } return 0; }