NGM - A Game with Numbers

no tags 

Nikifor and Trofim play the following game: they write some positive integer smaller than 2,000,000,000 and take turns one after another. Nikifor is the first to make a move. The turn is made by the following rule: from the written integer any non-zero digit is subtracted, and the new integer replaces the old one on the desk. For example for integer 40534, the next move can be: 40530, 40531 or 40529. The winner is the player who writes zero on the desk.

Write a program to decide who will win if both players do their best.

Input

The input contains the positive integer from which the game is started.

Output

In the first line you must write 1 if Nikifor wins and 2 otherwise. If Nikifor wins then in the second line you must output the move in the first turn which guarantees victory for him. If there are many such moves then output any of them.

Example

Input:
14

Output:
1
4

Author: Filimonenkov D.O.


hide comments
ramesh_961: 2017-06-03 06:53:59

Just Easy!!Think cool!! You will get definately!! O(1) solution!

sagnik_66: 2017-05-19 18:27:26

Extremely Easy!!

anupamwadhwa: 2017-05-14 19:38:43

O(1)

rohit9934: 2017-05-01 16:40:50

Hey! this is more easy than it looks.
HInt:Store numbers in strings.

jeelapamy: 2017-03-10 09:40:15

why is long long int gave wrong answer?

jasbir_123: 2017-03-01 12:58:23

If They are suppose to do their best.. Then it should be like
nikifor -> -4 = 10
-> -1 to -9 = 9 to 1
-> -9 to -1=0 to 0
hence there should be 3 moves in best cases.

nileskh2504: 2017-02-16 08:33:20

Please don't post the logic in the comments!
Let other tinker their brain!
Read problem statement carefully in case of WA!

tuandayhehe: 2017-02-16 03:59:45

wtf 's " do their best.". If they do their best then.
14 nikifor -> -4 = 10
so whatever trofim move (-1 to -9) nikifor wins after 2 moves. I can't get the problem. =.=

Last edit: 2017-02-16 04:00:17
nilabja16180: 2017-02-14 15:02:40

use int, not long long, got a WA

programminator: 2017-02-13 10:53:33

Easy


Added by:Roman Sol
Date:2006-05-05
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:ZCon 2007