PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000017. Đoạn nguyên tố ngắn nhất (Prime Segment)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đoạn nguyên tố ngắn nhất (Prime Segment)

Prime Segment

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given an integer nn, find an integer interval [a,b][a,b] containing nn (a≤n≤ba\le n\le b), where both endpoints aa and bb are primes. Minimize its length b−ab-a. Equal endpoints are allowed: if nn itself is prime, [n,n][n,n] is valid.

Input

One line contains the integer nn.

Output

Print two integers aa and bb, separated by a space, specifying the shortest prime-ended interval containing nn.

Subtasks

  • Subtask 1 (20 points): 2≤n≤1002\le n\le 100.
  • Subtask 2 (30 points): 2≤n≤10002\le n\le 1000.
  • Subtask 3 (50 points): 2≤n≤100002\le n\le 10000.

Examples

Input

10

Output

7 11

Explanation

The number 1010 is composite. The closest prime to its left is 77 and the closest prime to its right is 1111. Therefore [7,11][7,11] contains 1010, and neither endpoint can be moved closer while remaining prime.

Input

97

Output

97 97

Explanation

The number 9797 is prime. Taking a=b=97a=b=97 yields length 00, the minimum possible.