using System; using static System.Console; using System.Linq; using System.Collections.Generic; using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.Intrinsics.X86; using System.Runtime.Intrinsics.Arm; class Program { static int NN => int.Parse(ReadLine()); static long[] NList => ReadLine().Split().Select(long.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var x = NN; var f = new int[x + 1]; var mpd = GetMinPDivList(x); for (var i = 2; i <= x; ++i) { var plist = PDiv(i, mpd); var d = 1; var count = 0; for (var j = 0; j < plist.Count; ++j) { if (j > 0 && plist[j - 1] != plist[j]) { d *= count + 1; count = 1; } else ++count; if (j + 1 == plist.Count) d *= count + 1; } f[i] = i - d; } var min = int.MaxValue; for (var a = 1; a <= x / 2; ++a) { min = Math.Min(min, Math.Abs(f[a] - f[x - a])); } var ans = new List<(int a, int b)>(); for (var a = 1; a < x; ++a) { if (Math.Abs(f[a] - f[x - a]) == min) ans.Add((a, x - a)); } WriteLine(string.Join("\n", ans.Select(ai => $"{ai.a} {ai.b}"))); } static int[] GetMinPDivList(int max) { var minPDivList = new int[max + 1]; for (var i = 0; i <= max; ++i) minPDivList[i] = i; for (var i = 2; i * i <= max; ++i) if (minPDivList[i] == i) { for (var j = i * i; j <= max; j += i) if (minPDivList[j] == j) { minPDivList[j] = i; } } return minPDivList; } static int GetMinPDiv(int n, int min) { var p = min; while ((long)p * p <= n) { if (n % p == 0) return p; ++p; } return n; } static List PDiv(int n, int[] minPDivList) { var p = minPDivList[n]; if (n == p) { var dic = new List(); dic.Add(p); return dic; } else { var dic = PDiv(n / p, minPDivList); dic.Add(p); return dic; } } }