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
Ravi: 2015-07-26 14:17:29

Two Wrong answer for silly mistake
was printing 0 instead of 2 :@

Aditya: 2015-07-17 18:22:32

digit which user can subtract from Integer can only be digit from integer ?

Shantanu Banerjee: 2015-06-29 09:11:15

Tuffest Problem Ever! LOL! :D

radhika: 2015-06-13 17:54:38

hope you get it

Last edit: 2015-06-13 17:55:15
radhika: 2015-06-13 17:54:22

you need to mention the starting number the very first which gurantees victory i.e 4

Addy: 2015-06-07 23:59:43

Shortest code ever! :)

Manish Sombansh: 2015-06-04 14:11:57

smallest piece of code I've written in a long time!

ATUL GUPTA: 2015-05-18 18:32:02

I'm just one of the spoiling idiots here

Last edit: 2021-06-05 22:17:38
scyth3r: 2015-05-07 17:35:57

for every input....try to make Nikifor as winner

leo_messi: 2015-03-28 12:10:35

I may only be able to solve 1 problems aside of this one, but why not try and spoil it for everyone else just to conclusively prove my stupidity.

Last edit: 2021-06-05 22:18:56

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