#include<bits/stdc++.h>
using namespace std;
int yinzihe(int n){
int s=0;
for(int i=2;i<=n-1;i++){
if(n%i==0){
s+=i;
}
}
return s;
}
int main(){
int k;
cin>>k;
for(int i=2;i<=k;i++){
for(int j=2;j<=k;j++){
if(yinzihe(i)==j&&yinzihe(j)==i){
cout<<i<<" "<<j<<endl;
}
}
}
return 0;
}
/**************************************************************
Problem: 1140
User: linyuhang
Language: C++
Result: Accepted
Time:27 ms
Memory:2072 kb
****************************************************************/