23

Time limit: 0.1s Memory limit: 5MB Input: Output:

Bugland has a mixed population: bugs with 22 antennas and bugs with 33 antennas.

Clearly, the bugs with 22 antennas count in base 22 (they also consider that there are 1010 types of bugs in Bugland), and the bugs with 33 antennas count in base 33.

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 22 is not the same as the sum of the digits of the number written in base 33.

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 11 to NN, how many allowed numbers exist?

Input data

The first line will contain the number TT of scenarios.

The next TT lines each contain one number NN, 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 TT numbers, separated by spaces, the ithi^{th} number representing the answer to the ithi^{th} scenario.

Constraints and clarifications

  • 1T1 0001 \leq T \leq 1 \ 000;
  • 1Ni1071 \leq N_i \leq 10^7;
  • For tests worth 2020 points: 1Ni1061 \leq \sum N_i \leq 10^6.
  • For other tests worth 3030 points: 1Ni1061 \leq N_i \leq 10^6.

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 11 to 1010 are written in base 22 and base 33 like this:

base 1010 base 22 base 33 the sum in base 22 the sum in base 33
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: 11, 66, 77, 1010.

Log in or sign up to be able to send submissions!