While playing a mental math game, you realize that the number k is mathematically beautiful.
You then realize that the number x can be mathematically beautiful if it is represented as a sum of a sequence where each element is a power of k and all the numbers in the sequence are different.
Task
Your task is to determine whether the number is mathematically beautiful.
Input format
Output Format
For each test case, output "YES" if x is "mathematically beautiful" and "NO" otherwise.
Constraints
T<=1000
(1<=x<=1018)
(2<=k<=9)
91=30+32+34