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

#SP0000034. Thắng hay chịu rét (Win or Freeze)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Thắng hay chịu rét (Win or Freeze)

Win or Freeze

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Two players play a game starting with a positive integer qq. Players alternate moves. On a move, a player must choose a nontrivial divisor dd of the current integer (1<d<1<d< current integer), and replace the current integer with dd.

Special win condition: the first player who cannot make a legal move wins. Both players play optimally. Determine whether player one or two wins. If player one wins and has a legal move, print any winning first move. If player one wins immediately because there is no legal move, print 00.

Input

One line containing the positive integer qq.

Output

Print 1 if player one wins or 2 if player two wins on the first line. If the first line is 1, print a winning first-move divisor dd on the second line, or 0 when no move exists.

Subtasks

  • Subtask 1 (20 points): 1≤q≤1051\le q\le10^5.
  • Subtask 2 (30 points): 1≤q≤1091\le q\le10^9.
  • Subtask 3 (50 points): 1≤q≤10131\le q\le10^{13}.

Examples

Input

6

Output

2

Explanation

From 66 the first player can choose only 22 or 33. Each is prime, so player two will have no move and therefore wins.

Input

30

Output

1
6

Explanation

Player one chooses d=6d=6, a nontrivial divisor of 3030. Player two must choose either 22 or 33, leaving player one with no move and the win.

Input

1

Output

1
0

Explanation

With q=1q=1 there is no legal nontrivial divisor; player one wins immediately and prints 0.