#P2425. 小红帽的回文数

小红帽的回文数

Description

Little Red Riding Hood likes palindromic numbers, but numbers in real life are often not palindromes. Now she has tt numbers. She knows that each of these tt numbers is a palindrome in base xx (x2x \ge 2). For each number, find the smallest such base xx.

Input Format

The first line contains an integer tt (1t10001 \le t \le 1000). Each of the next tt lines contains a number aia_i (0ai10100 \le a_i \le 10 ^ {10}).

Output Format

Output tt lines. Each line contains the required xx.

4
1
4
21
345332
2
3
2
114

Hint

11 in binary is 11, and 44 in base 33 is 1111. 2121 in base 22 is 1 0 1 0 11\ 0\ 1\ 0\ 1, and 345332345332 in base 114114 is 26 65 2626\ 65\ 26.

Translated by ChatGPT 5