import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int[] counts = new int[x + 1]; for (int i = 1; i <= x; i++) { counts[i] = i - getCount(i); } int min = Integer.MAX_VALUE; Answer.size = x; ArrayList list = new ArrayList<>(); for (int i = 1; i <= x / 2; i++) { if (min >= Math.abs(counts[i] - counts[x - i])) { if (min > Math.abs(counts[i] - counts[x - i])) { list.clear(); min = Math.abs(counts[i] - counts[x - i]); } list.add(new Answer(i)); if (i * 2 < x) { list.add(new Answer(x - i)); } } } Collections.sort(list); StringBuilder sb = new StringBuilder(); for (Answer a : list) { sb.append(a).append("\n"); } System.out.print(sb); } static int getCount(int x) { if (x == 1) { return 1; } else { int count = 2; for (int i = 2; i <= Math.sqrt(x); i++) { if (x % i != 0) { continue; } if (i * i == x) { count++; } else { count += 2; } } return count; } } static class Answer implements Comparable { static int size; int left; int right; public Answer(int left, int right) { this.left = left; this.right = right; } public Answer(int left) { this(left, size - left); } public int compareTo(Answer another) { return left - another.left; } public String toString() { return new StringBuilder().append(left).append(" ").append(right).toString(); } } }