#define _USE_MATH_DEFINES #include using namespace std; vector sieve (int n) { vector res(n + 1); iota(res.begin(), res.end(), 0); for (int i = 2; i <= n; i++) { if (res[i] != i) continue; for (int j = i + i; j <= n; j += i) { res[j] = i; } } return res; } signed main() { ios::sync_with_stdio(false); cin.tie(0); int x; cin >> x; auto table = sieve(x); vector cnt(x + 1); auto f = [&] (int k) { long long kk = k; vector appear; while (k > 1) { cnt[table[k]]++; appear.push_back(table[k]); k /= table[k]; } long long res = 1; for (int i : appear) { if (cnt[i] > 0) { res *= cnt[i] + 1; cnt[i] = 0; } } return kk - res; }; long long mi = 1 << 30; for (int i = 1; i <= x / 2; i++) mi = min(mi, abs(f(i) - f(x - i))); vector> ans; for (int i = 1; i <= x; i++) if (abs(f(i) - f(x - i)) == mi) ans.emplace_back(i, x - i); for (auto& p : ans) { cout << p.first << " " << p.second << '\n'; } return 0; }