Eureka Theorem

No attempts yetTime limit1sMemory limit256 MB

Problem

The triangular number TnT_n (n1n \ge 1) counts dots stacked in the shape of a triangle: 1 dot in the first row, 2 in the second row, and nn dots in the nnth row.

Tn=1+2+3++n=n(n+1)2T_n = 1 + 2 + 3 + \cdots + n = \frac{n(n+1)}{2}

In 1796 Gauss proved that every natural number is the sum of at most three triangular numbers. For example:

  • 4=T1+T24 = T_1 + T_2
  • 5=T1+T1+T25 = T_1 + T_1 + T_2
  • 6=T2+T26 = T_2 + T_2 or 6=T36 = T_3
  • 10=T1+T2+T310 = T_1 + T_2 + T_3 or 10=T410 = T_4

Gauss wrote "Eureka! num = Δ+Δ+Δ\Delta + \Delta + \Delta" in his diary to mark the proof, and the result is known as the Eureka theorem because of that line. Kkung wondered which natural numbers are the sum of exactly three triangular numbers. In the examples above, 5 and 10 are such sums, but 4 and 6 are not.

Given a natural number, write a program that decides whether it is the sum of exactly three triangular numbers. The three triangular numbers do not have to be distinct.

Input

The first line contains the number of test cases TT. Each of the next TT lines contains one natural number KK (3K10003 \le K \le 1000).

Output

Print one line per test case. Print 1 if KK is the sum of exactly three triangular numbers, and 0 otherwise.