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 - 1; } for (int i = 2; i <= x; i++) { for (int j = 1; j * i <= x; j++) { counts[j * 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 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(); } } }