#CT0000064. Số chính phương gần nhất - EP1 (Nearest Perfect Square - EP1)

Số chính phương gần nhất - EP1 (Nearest Perfect Square - EP1)

Nearest Perfect Square - EP1

Version: Phuoc Hung OJ Extended

Problem Statement

A positive integer is called a perfect square if it is the square of a positive integer. For example, 1,4,9,16,251,4,9,16,25 are perfect squares.

You are given a positive integer NN. For each perfect square SS, define its distance to NN as ∣N−S∣|N-S|.

Find the perfect square SS with minimum distance to NN, and also output the minimum distance D=∣N−S∣D=|N-S|.

Input

One line containing the positive integer NN.

Output

Print two integers SS and DD, where SS is the perfect square closest to NN and D=∣N−S∣D=|N-S|.

Subtasks

  • Subtask 1 (30 points): 1≤N≤1061 \le N \le 10^6.
  • Subtask 2 (30 points): 1≤N≤10121 \le N \le 10^{12}.
  • Subtask 3 (40 points): 1≤N≤10181 \le N \le 10^{18}.

Examples

Example 1

Input

20

Output

16 4

Explanation

The two perfect squares around 20 are 42=164^2=16 and 52=255^2=25. Their distances are 4 and 5, so the answer is 16 with distance 4.

Example 2

Input

24

Output

25 1

Explanation

25=5225=5^2 and ∣24−25∣=1|24-25|=1, so the answer is 25 1.

Example 3

Input

30

Output

25 5

Explanation

The adjacent perfect squares are 25=5225=5^2 and 36=6236=6^2. Their distances are 5 and 6, so 25 is closer.

Example 4

Input

81

Output

81 0

Explanation

81=9281=9^2 is already a perfect square, so the minimum distance is 0.

Example 5

Input

999999999999999999

Output

1000000000000000000 1

Explanation

1018=(109)210^{18}=(10^9)^2 is exactly one greater than NN, so it is the closest perfect square.