CF2048A.Kevin and Combination Lock

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Kevin and Combination Lock

Kevin is trapped in Lakeside Village by Grace. At the exit of the village, there is a combination lock that can only be unlocked if Kevin solves it.

The combination lock starts with an integer xx. Kevin can perform one of the following two operations zero or more times:

  1. If x33x \neq 33, he can select two consecutive digits 33 from xx and remove them simultaneously. For example, if x=13323x = 13\,323, he can remove the second and third 33, changing xx to 123123.
  2. If x33x \geq 33, he can change xx to x33x - 33. For example, if x=99x = 99, he can choose this operation to change xx to 9933=6699 - 33 = 66.

When the value of xx on the combination lock becomes 00, Kevin can unlock the lock and escape from Lakeside Village. Please determine whether it is possible for Kevin to unlock the combination lock and escape.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1041 \le t \le 10^4).

The only line of each test case contains a positive integer xx (1x1091\leq x\leq 10^9).

Output

For each test case, output "YES" or "NO" (without quotes) in one line, representing whether Kevin can unlock the combination lock and escape. You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Note

For the first test case, $165\xrightarrow{-33}132\xrightarrow{-33}99\xrightarrow{-33}66\xrightarrow{-33}33\xrightarrow{-33}0$.

For the second test case, $6369\xrightarrow{-33}6{\color{red}{33}}6\xrightarrow{\text{remove "33"}}66\xrightarrow{-33}33\xrightarrow{-33}0$.

For the third test case, it can be proven that, regardless of the operations performed, 666666 cannot be transformed into 00.

Samples

5
165
6369
666
114514
133333332
YES
YES
NO
NO
YES

在线编程 IDE

建议全屏模式获得最佳体验