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

#SP0000030. Rút gọn về số nguyên tố (Prime Reduction)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Rút gọn về số nguyên tố (Prime Reduction)

Prime Reduction

Source: Kattis

Version: Phuoc Hung OJ Extended

Problem Statement

An integer x≥2x\ge2 is prime if its only positive divisors are 11 and itself. Every composite integer has a prime factorization, including repeated prime factors.

Perform prime reduction as follows:

  1. Check whether xx is prime. If so, stop.
  2. If xx is composite, factorize it into primes p1,p2,…,pkp_1,p_2,\ldots,p_k, including repetitions.
  3. Replace xx by the sum p1+p2+⋯+pkp_1+p_2+\cdots+p_k, then return to Step 1.

Find the final prime and the number of executions of Step 1, including the final check when xx is prime. The value x=4x=4 is excluded because 4=2+24=2+2 and the procedure would never terminate.

Input

One line containing the initial integer xx.

Output

Output two integers on one line, separated by one space: the final prime and the number of primality-check steps.

Subtasks

  • Subtask 1 (20 points): 2≤x≤1002\le x\le100; x≠4x\ne4.
  • Subtask 2 (30 points): 2≤x≤1052\le x\le10^5; x≠4x\ne4.
  • Subtask 3 (50 points): 2≤x≤1092\le x\le10^9; x≠4x\ne4.

Examples

Example 1

Input

76

Output

23 2

Explanation: First check: 7676 is composite, with 76=2⋅2⋅1976=2\cdot2\cdot19. The sum 2+2+19=232+2+19=23 becomes the new value. Second check: 2323 is prime, so stop. Output 23 2.

Example 2

Input

100

Output

5 5

Explanation: The sequence is 100→14→9→6→5100\to14\to9\to6\to5. The sums of prime factors are 2+2+5+5=142+2+5+5=14, then 2+7=92+7=9, then 3+3=63+3=6, then 2+3=52+3=5. Since 55 is prime, five checks were performed. Output 5 5.

Example 3

Input

2

Output

2 1

Explanation: The first primality check finds that 22 is prime, so no reduction occurs. There is still one check.