Under construction

Still being built. Things may change

Sum of Primes

Interview

Time limit15sMemory limit1024 MB

Summary
Given N, find a contiguous run of consecutive primes whose sum is exactly N, or print NIE if no such run exists.
Level

Medium5 of 10

Topics
Two pointers, Sliding window, Math
Solved
No attempts yet

Statement

A natural number nn is called prime if it has exactly two distinct divisors, 11 and nn. For example, 66 is not prime because 22 divides it, and 11 is not prime because its only divisor is 11. The numbers 22 and 77 are prime.

Problem

Bajtazar loves prime numbers. He wrote consecutive primes on a sheet of paper: 2,3,5,7,11,13,17,19,23,29,31,…2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, \ldots He wants to choose a contiguous segment of this sequence whose sum is exactly his favorite number NN. Write a program that, given NN, finds any contiguous interval of the prime sequence whose sum is exactly NN.

Input

The first and only line of input contains one natural number NN (1≤N≤10111 \le N \le 10^{11}), the sum Bajtazar wants.

Output

The first and only line of output should contain two primes LL and RR (1≤L≤R≤N1 \le L \le R \le N) such that the sum of the primes in the closed interval [L,R][L, R] is exactly NN. If there are several solutions, your program may output any of them. If no solution exists, output only the single word NIE.

Examples1

  1. Example 1

    Input
    15
    
    Expected output
    3 7