Bugland has a mixed population: bugs with antennas and bugs with antennas.
Clearly, the bugs with antennas count in base (they also consider that there are types of bugs in Bugland), and the bugs with antennas count in base .
A number is considered improper if the sum of the digits is different in the eyes of the two species of bugs. In other words, a number is considered improper if the sum of the digits of the number written in base is not the same as the sum of the digits of the number written in base .
In order to promote the equality of the two species of bugs, improper numbers are forbidden.
Task
Considering that the bugs know how to count only from to , how many allowed numbers exist?
Input data
The first line will contain the number of scenarios.
The next lines each contain one number , the highest number the bugs know to count to. Please note that the bugs only know positive integer numbers.
Output data
The first line will contain numbers, separated by spaces, the number representing the answer to the scenario.
Constraints and clarifications
- ;
- ;
- For tests worth points: .
- For other tests worth points: .
Example
stdin
10
1 2 3 4 5 6 7 8 9 10
stdout
1 1 1 1 1 2 3 3 3 4
Explanation
The numbers from to are written in base and base like this:
base | base | base | the sum in base | the sum in base |
---|---|---|---|---|
1 | 1 | 1 | 1 | 1 |
2 | 10 | 2 | 1 | 2 |
3 | 11 | 10 | 2 | 1 |
4 | 100 | 11 | 1 | 2 |
5 | 101 | 12 | 2 | 3 |
6 | 110 | 20 | 2 | 2 |
7 | 111 | 21 | 3 | 3 |
8 | 1000 | 22 | 1 | 4 |
9 | 1001 | 100 | 2 | 1 |
10 | 1010 | 101 | 2 | 2 |
Therefore, the only allowed numbers are: , , , .