#include #define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i)) #define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i)) #define rep(i, n) For((i), 0, (n)) #define rrep(i, n) rFor((i), (n), 0) #define fi first #define se second using namespace std; typedef long long lint; typedef unsigned long long ulint; typedef pair pii; typedef pair pll; template bool chmax(T &a, const T &b){if(a bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;} template T div_floor(T a, T b){ if(b < 0) a *= -1, b *= -1; return a>=0 ? a/b : (a+1)/b-1; } template T div_ceil(T a, T b){ if(b < 0) a *= -1, b *= -1; return a>0 ? (a-1)/b+1 : a/b; } constexpr lint mod = 1e9+7; constexpr lint INF = mod * mod; constexpr int MAX = 100010; vector min_factor, prime; void sieve(int n){ min_factor.resize(n+1, 0); For(i, 2, n+1){ if(min_factor[i] == 0){ min_factor[i] = i; prime.push_back(i); } for(int x: prime){ if(x*i > n || x > i) break; min_factor[x*i] = x; } } } vector prime_f(int n){ vector ret; while(n > 1){ if(ret.empty() || ret.rbegin()->fi != min_factor[n]){ ret.emplace_back(min_factor[n], 1); } else ++ret.rbegin()->se; n /= min_factor[n]; } return ret; } int main(){ int x; scanf("%d", &x); sieve(x); vector a; int f[x]; For(i, 1, x){ auto v = prime_f(i); int tmp = 1; for(auto p: v) tmp *= (p.se + 1); f[i] = i - tmp; } vector ans; int val = mod; For(i, 1, x){ if(chmin(val, abs(f[i] - f[x-i]))){ ans.clear(); ans.emplace_back(i, x-i); } else if(val == abs(f[i] - f[x-i])) ans.emplace_back(i, x-i); } sort(ans.begin(), ans.end()); for(auto p: ans) printf("%d %d\n", p.fi, p.se); }