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 k as (anan−1…a1a0)k, where each digit ai is an integer with 0≤ai<k.
The value of (anan−1…a1a0)k is an⋅kn+an−1⋅kn−1+⋯+a1⋅k+a0. For example, the base-10 number 12310 has value 1⋅100+2⋅10+3, and the base-8 number 1238 has value 1⋅64+2⋅8+3.
Given an integer n in base 10, write a program that finds every base among 2,3,…,10 in which n is a palindrome.
The first line contains the integer n. (1≤n≤101000)
If n is not a palindrome in any of the bases 2,3,…,10, print NIE. Otherwise, for each base b in which n is a palindrome, print the base b and the representation m of n in base b on their own line, in the format b m. Print the bases in increasing order of b.
For example, n=15 is 1111 in base 2 and 33 in base 4, so it is a palindrome in both. (1⋅23+1⋅22+1⋅2+1=3⋅4+3=15)