Algorithm


C. Win or Freeze
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circles around the hotel. Let us remind you that a number's divisor is called non-trivial if it is different from one and from the divided number itself.

The first person who can't make a move wins as he continues to lie in his warm bed under three blankets while the other one keeps running. Determine which player wins considering that both players play optimally. If the first player wins, print any winning first move.

Input

The first line contains the only integer q (1 ≤ q ≤ 1013).

Please do not use the %lld specificator to read or write 64-bit integers in ะก++. It is preferred to use the cincout streams or the %I64d specificator.

Output

In the first line print the number of the winning player (1 or 2). If the first player wins then the second line should contain another integer — his first move (if the first player can't even make the first move, print 0). If there are multiple solutions, print any of them.

Examples
input
Copy
6
output
Copy
2
input
Copy
30
output
Copy
1
6
input
Copy
1
output
Copy
1
0
Note

Number 6 has only two non-trivial divisors: 2 and 3. It is impossible to make a move after the numbers 2 and 3 are written, so both of them are winning, thus, number 6 is the losing number. A player can make a move and write number 6 after number 306, as we know, is a losing number. Thus, this move will bring us the victory.



 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include <bits/stdc++.h>

using namespace std;

long long q, sqrtq;
vector <int> fact;

int main() {
  scanf("%lld", &q);

  sqrtq = sqrt(q) + 1;

  for(int i = 2; i  <= sqrtq; ++i)
  	while(q % i == 0)
  		fact.push_back(i), q /= i;
  if(q > 1)
  	fact.push_back(q);

  if(fact.size()  <= 1)
  	puts("1\n0");
  else if(fact.size() == 2)
  	puts("2");
  else {
  	puts("1");
  	printf("%lld\n", 1ll * fact[0] * fact[1]);
  }

  return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
6

Output

x
+
cmd
2
Advertisements

Demonstration


Codeforcess Solution  Win or Freeze, C. Win or Freeze C,C++, Java, Js and Python ,Win or Freeze,C. Win or Freeze

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+