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
markaman: 2018-12-27 17:58:10

EASY HAI BHAI PAPER WORK KARO...

harry_shit: 2018-09-04 13:04:06

easy one but great logic!!

bhaskar_06: 2018-07-26 16:23:50

natak tha be

vaibhavmishra: 2018-07-11 22:46:47

AC in 8 lines of python... :)

ajayc1007: 2018-06-15 08:23:53

SPOILERS ;(

incomplet_: 2018-04-17 09:44:55

Best move means that they try their best to win the game, it does not mean the largest number in each turn

srjsunny: 2018-01-24 16:04:57

long long int will work

bani_raheja: 2018-01-15 10:23:09

Last edit: 2018-12-26 19:13:34
michaelscof: 2017-10-29 09:50:26

The easiest one on spoj.just pen and paper needed.

hitesh87: 2017-10-05 13:26:13

easy AC in one go!!!


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