Palindrome Numbers

No attempts yetTime limit1sMemory limit128 MB

Problem

A palindrome is a string that reads the same forwards and backwards. For example, ala and aa are palindromes, while adam is not.

Every integer can be written in base kk as (anan1a1a0)k(a_n a_{n-1} \dots a_1 a_0)_k, where each digit aia_i is an integer with 0ai<k0 \le a_i < k.

The value of (anan1a1a0)k(a_n a_{n-1} \dots a_1 a_0)_k is ankn+an1kn1++a1k+a0a_n \cdot k^n + a_{n-1} \cdot k^{n-1} + \cdots + a_1 \cdot k + a_0. For example, the base-10 number 12310123_{10} has value 1100+210+31 \cdot 100 + 2 \cdot 10 + 3, and the base-8 number 1238123_8 has value 164+28+31 \cdot 64 + 2 \cdot 8 + 3.

Given an integer nn in base 10, write a program that finds every base among 2,3,,102, 3, \dots, 10 in which nn is a palindrome.

Input

The first line contains the integer nn. (1n1010001 \le n \le 10^{1000})

Output

If nn is not a palindrome in any of the bases 2,3,,102, 3, \dots, 10, print NIE. Otherwise, for each base bb in which nn is a palindrome, print the base bb and the representation mm of nn in base bb on their own line, in the format b m. Print the bases in increasing order of bb.

Hint

For example, n=15n = 15 is 11111111 in base 2 and 3333 in base 4, so it is a palindrome in both. (123+122+12+1=34+3=151 \cdot 2^3 + 1 \cdot 2^2 + 1 \cdot 2 + 1 = 3 \cdot 4 + 3 = 15)