ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

2176. Wonderful Numbers

Time limit: 1.0 second
Memory limit: 256 MB
Recently, Kostya learned that there are numbers whose representation in the ternary numeral system appears as a substring in their representation in the binary system. He called such numbers beautiful. For example, the number 1210 = 1103 = 11002 is beautiful because the string “110” is a substring of “1100”.
Now Kostya decided to come up with an interesting definition related to beautiful numbers, after which he would create a problem in computer science based on it. He called a number X wonderful if it can be expressed as a sum of distinct beautiful numbers. According to this definition, the number 22 = 10 + 12 is wonderful, while the number 3 is not. It is also worth noting that by definition, all beautiful numbers are also wonderful.
Your task is to determine for several natural numbers whether they are wonderful or not.

Input

The first line contains a single integer N — the number of numbers being considered (1 ≤ N ≤ 1000).
The second line contains N integers xi, for each of which you need to determine whether it is wonderful (1 ≤ xi ≤ 109).

Output

In the i-th line, you need to output one string “YES” if the number xi is wonderful, or the string “NO” otherwise.

Samples

inputoutput
6
1 2 3 8 9 10
YES
NO
NO
NO
YES
YES
4
854789369 694089367 789789379 795089367
NO
YES
NO
YES
Problem Author: Konstantin Rychkov
Problem Source: Ural School Programming Contest 2023