atcoder#ARC144A. [ARC144A] Digit Sum of 2x

[ARC144A] Digit Sum of 2x

Score : 300300 points

Problem Statement

For a positive integer xx, let f(x)f(x) be the sum of its digit. For example, f(144)=1+4+4=9f(144) = 1+4+4 = 9 and f(1)=1f(1)=1.

You are given a positive integer NN. Find the following positive integers MM and xx:

  • The maximum positive integer MM for which there exists a positive integer xx such that f(x)=Nf(x)=N and f(2x)=Mf(2x)=M.
  • The minimum positive integer xx such that f(x)=Nf(x)=N and f(2x)=Mf(2x)=M for the MM above.

Constraints

  • 1N1051\leq N\leq 10^5

Input

Input is given from Standard Input in the following format:

NN

Output

Print MM in the first line and xx in the second line.

3
6
3

We can prove that whenever f(x)=3f(x)=3, f(2x)=6f(2x) = 6. Thus, M=6M=6. The minimum positive integer xx such that f(x)=3f(x)=3 and f(2x)=6f(2x)=6 is x=3x=3. These MM and xx should be printed.

6
12
24
100
200
4444444444444444444444444