#include using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i < (n); i++) template istream& operator >> (istream& s, vector& v) { for (T& x: v) { s >> x; } return s;} template inline bool chmin(T& a, T b) {return a>b?a=b,true:false;} int main() { int X; cin >> X; vector divs(X+1, 1); divs[0] = 0; for (int i = 2; i <= X; i++) { divs[i]++; for (int j = i+i; j <= X; j += i) { divs[j]++; } } int least = INT_MAX; vector diff(X/2 + 1); for (int a = 1; a < diff.size(); a++) { int b = X - a; diff[a] = abs(a - divs[a] - (b - divs[b])); chmin(least, diff[a]); } vector> rev; for (int a = 1; a < diff.size(); a++) { if (diff[a] == least) { int b = X - a; cout << a << " " << b << endl; if (a != b) rev.push_back(make_pair(b, a)); } } for (auto it = rev.rbegin(); it != rev.rend(); it++) { cout << (*it).first << " " << (*it).second << endl; } }