This page is still under construction.

Parts of this page are still being built. What you see may change.

Fake Prime

Time limit2sMemory limit512 MB

Summary
Find the smallest composite n > L that passes the Fermat test for every base 2..500, and print its smallest prime factor.
Level

Hard8 of 10

Topics
Number theory, Math, Binary search
Solved
No attempts yet

Problem

Jigui met a problem that is only solvable after deciding whether a number around ten billion is prime. He wrote code that divides by every integer from 2 to N\sqrt{N}, but it produced no result after an hour. A search turned up Fermat's little theorem.

For a prime pp and every natural number aa with gcd⁡(a,p)=1\gcd(a, p) = 1, ap−1≡1(modp)a^{p-1} \equiv 1 \pmod p.

Jigui used it backwards and wrote code that reports nn as prime when 2n−1≡1(modn)2^{n-1} \equiv 1 \pmod n. That code classified 561 as prime. Jigui did not give up, widened the set of bases, and settled on the following test.

Given a natural number nn, if every integer aa with 2≤a≤5002 \le a \le 500 satisfies an−1≡1(modn)a^{n-1} \equiv 1 \pmod n, report nn as prime. If even one of them fails, report nn as composite.

Jigui checked every number up to one million by computer, submitted the answer with confidence, and was wrong again. When n>500n > 500 a prime is always reported as prime, so the only way this test errs is by reporting a composite number as prime. Call such an nn a counterexample.

Show Jigui a counterexample. Given an integer LL, find the smallest counterexample greater than LL and the smallest prime factor of that counterexample.

Input

The first line contains an integer LL. (500≤L≤1012500 \le L \le 10^{12})

Output

On the first line, print the smallest counterexample nn greater than LL and the smallest prime factor mm of nn, separated by a space. The answer nn is always at most 101510^{15}, and mm satisfies 1<m<n1 < m < n.

Examples2

  1. Example 1

    Input
    500
    
    Expected output
    413138881 617
  2. Example 2

    Input
    413138881
    
    Expected output
    1207252621 613