Palindromic in Which Bases?
A number is a palindrome in base b if its digits in base b, written without leading zeros, read the same from left to right and from right to left. For example, 9 is 1001 in base 2, so it is a palindrome in base 2, while in base 10 it is the single digit 9, which is a palindrome too.
You are given q positive integers. For each of them, find every base b with 2 ≤ b ≤ 36 in which it is a palindrome.
A digit in base b is a value from 0 to b − 1. Compare digit values, not their printed forms: in base 12, the number 133 has the two digits 11 and 1, so it is not a palindrome.
Input
The first line contains an integer q (1 ≤ q ≤ 10^4), the number of queries.
Each of the next q lines contains one integer n (1 ≤ n ≤ 10^18). Note that n does not fit in a 32-bit integer.
Output
For each query, print one line: the bases in which n is a palindrome, in increasing order and separated by single spaces, or the word NONE if there are no such bases.
Notes
In the first example, 1 is a single digit in every base, so all 35 bases are listed. 5 is 101 in base 2, 12 in base 3, 11 in base 4, and a single digit 5 in every base from 6 upward.