The Ada programming language allows integer constants written in forms such as 123, 8#123#, and 16#abc#. These represent the integers 123, 83 (123 read in base 8), and 2739 (abc read in base 16).
An integer constant is one of the following:
0–9).#, then one or more digits, then a closing #. Each digit must be strictly less than the base. The letters a through f stand for the digit values 10 through 15.In real Ada the base must be written in decimal, but in this problem the base itself may be written in any of the forms above, as long as its value is an integer between 2 and 16 inclusive. For example, in 2#101##123# the base of the second group is 2#101#, whose value is 5.
For each given string, decide whether the whole string is a valid integer constant.
The first line contains a positive integer $n$. Each of the next $n$ lines contains one string. Each string contains no spaces and has length between 1 and 80 characters.
For each input string, print yes on its own line if it is a valid integer constant according to the rules above; otherwise print no.