#include<stdio.h>
int main(void)
{
    int masatoy, kouay, i, k, max1=5, max2=7;
    scanf("%d", &masatoy);
    while (masatoy != 0) {
        for (i = 1; i <= masatoy; i++) {
            if (i + 2 > masatoy)break;
            if (i!= 1 || i != 2 || i != 3) {
                if (i%2 != 0 && i % 3 != 0 && i % 5 != 0 && i % 7 != 0) {
                    if ((i + 2) % 2 != 0 && (i + 2) % 3 != 0 && (i + 2) % 5 != 0 && (i + 2 )% 7 != 0) {
                        if (max1 < i) {
                            max1 = i;
                            max2 = i + 2;
                        }
                    }
                }

            }
        }
        printf("%d %d\n", max1,max2);
            scanf("%d", &masatoy);
            max1 = 5;
            max2 = 7;
    }
    return 0;
}