#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } constexpr long long MAX = 5100000; constexpr long long INF = 1LL << 60; constexpr int inf = 1 << 28; constexpr long long mod = 1000000007LL; //constexpr long long mod = 998244353LL; using namespace std; typedef unsigned long long ull; typedef long long ll; bool IsPrime[MAX]; ll MinFactor[MAX]; vector preprocess(ll n = MAX) { vector res; for (ll i = 0; i < n; ++i) IsPrime[i] = true, MinFactor[i] = -1; IsPrime[0] = false; IsPrime[1] = false; MinFactor[0] = 0; MinFactor[1] = 1; for (ll i = 2; i < n; ++i) { if (IsPrime[i]) { MinFactor[i] = i; res.push_back(i); for (ll j = i * 2; j < n; j += i) { IsPrime[j] = false; if (MinFactor[j] == -1) MinFactor[j] = i; } } } return res; } vector > fast_prime_factor(ll n) { vector > res; while (n != 1) { ll prime = MinFactor[n]; ll exp = 0; while (MinFactor[n] == prime) { ++exp; n /= prime; } res.push_back(make_pair(prime, exp)); } return res; } int main() { /* cin.tie(nullptr); ios::sync_with_stdio(false); */ preprocess(); ll X; scanf("%lld", &X); if (X == 2) { cout << "1 1" << endl; return 0; } vector> res; ll ans = INF; vector cnt(X + 1, 1); for (int i = 1; i <= X; i++) { vector> vp = fast_prime_factor(i); for (auto p : vp) { cnt[i] *= (p.second + 1); } } for (ll a = 1; a < X; a++) { ll b = X - a; ll cnt1 = cnt[a], cnt2 = cnt[b]; ll res1 = a - cnt1; ll res2 = b - cnt2; chmin(ans, llabs(res1 - res2)); } for (ll a = 1; a < X; a++) { ll b = X - a; ll cnt1 = cnt[a], cnt2 = cnt[b]; ll res1 = a - cnt1; ll res2 = b - cnt2; if (llabs(res1 - res2) == ans) { res.emplace_back(a, b); } } for (int i = 0; i < res.size(); i++) { printf("%lld %lld\n", res[i].first, res[i].second); } return 0; /* おまじないを使ったらscanfとprintf関連注意!!!!!!!!!!!! */ }