You are given an integer $x$. Can you make $x$ by summing up some number of $11, 111, 1111, 11111, \ldots$? (You can use any number among them any number of times).

For instance,

$33=11+11+11$

$144=111+11+11+11$


-----Input-----

The first line of input contains a single integer $t$ $(1 \leq t \leq 10000)$ — the number of testcases.

The first and only line of each testcase contains a single integer $x$ $(1 \leq x \leq 10^9)$ — the number you have to make.


-----Output-----

For each testcase, you should output a single string. If you can make $x$, output "YES" (without quotes). Otherwise, output "NO".

You can print each letter of "YES" and "NO" in any case (upper or lower).


-----Examples-----

Input
3
33
144
69
Output
YES
YES
NO


-----Note-----

Ways to make $33$ and $144$ were presented in the statement. It can be proved that we can't present $69$ this way.

Difficulty: MEDIUM
Tags: Number theory

Dynamic programming

Mathematics
Skill types: Dynamic programming

Starter code:

Solutions:
print('\n'.join(['YES' if (n := int(input())) >= 111 * (n % 11) else 'NO' for _ in range(int(input()))]))


import math
from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	if n >= 1100:
		print('YES')
		continue
	q = n // 11
	rem = n % 11
	q = q // 10
	if rem <= q:
		print('YES')
	else:
		print('NO')


import random
import sys
input = sys.stdin.readline

def main():
	tests = int(input())
	for t in range(tests):
		x = int(input())
		if x >= x % 11 * 111:
			print('YES')
		else:
			print('NO')
main()


import time

def main():
	t = i_input()
	for tt in range(t):
		x = i_input()
		r = x % 11
		d = x // 11 // 10
		if r > d:
			print('NO')
		else:
			print('YES')

def i_input():
	return int(input())

def l_input():
	return input().split()

def li_input():
	return list(map(int, l_input()))

def il_input():
	return list(map(int, l_input()))
TT = time.time()
main()


import sys
from pprint import pprint

def do():
	a = int(input())
	can = False
	for i in range(25):
		x = a - 111 * i
		if x < 0:
			break
		if x % 11 == 0:
			can = True
	print('YES' if can else 'NO')
q = int(input())
for _ in range(q):
	do()


for _ in range(int(input())):
	s = input()
	n = int(s)
	leng = len(s)
	found = False
	if n < 10:
		found = False
	if n % 11 == 0:
		found = True
	if n % 11 <= n / 111:
		found = True
	else:
		found = False
	if found:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	if n >= 111 * (n % 11):
		print('YES')
	else:
		print('NO')


def get_list():
	p = [False for _ in range(10 * 110 + 1)]
	for x in range(111 + 1):
		for y in range(11 + 1):
			if 11 * x + 111 * y < len(p):
				p[11 * x + 111 * y] = True
	return p
n = int(input())
p = get_list()
for i in range(n):
	num = int(input())
	if num >= len(p):
		print('YES')
	else:
		print('YES' if p[num] else 'NO')


for _ in range(int(input())):
	x = int(input())
	f = 0
	while x > 0:
		if x % 11 == 0 or x % 111 == 0:
			f = 1
			break
		x -= 111
	if f == 1:
		print('YES')
	else:
		print('NO')


j = int(input())
while j > 0:
	i = int(input())
	t = i % 11
	if 111 * t <= i:
		print('YES')
	else:
		print('NO')
	j = j - 1


for i in range(int(input())):
	x = int(input())
	ans = 0
	while x > 0:
		if x % 11 == 0 or x % 111 == 0:
			ans = 1
			break
		x -= 111
	if ans:
		print('YES')
	else:
		print('NO')


def ys(n):
	if n >= 111 * (n % 11):
		return 'YES'
	return 'NO'
for i in range(int(input())):
	print(ys(int(input())))


n = int(input())
while n > 0:
	z = int(input())
	b = False
	for i in range(12):
		if z < 111 * i:
			break
		if (z - 111 * i) % 11 == 0:
			print('YES')
			b = True
			break
	if b == False:
		print('NO')
	n -= 1


def sum(n):
	greatest = 11 * 111 - 11 - 111
	if n > greatest:
		return 'YES'
	elif n % 11 <= n // 111:
		return 'YES'
	else:
		return 'NO'
ans = []
for x in range(int(input())):
	ans.append(sum(int(input())))
for y in ans:
	print(y)


k = int(input())
for i in range(k):
	n = int(input())
	if n > 1099:
		print('YES')
	else:
		while True:
			if n % 11 == 0:
				print('YES')
				break
			n -= 111
			if n < 0:
				print('NO')
				break


testcases = int(input())
for testcase in range(testcases):
	n = int(input())
	if n <= 10:
		print('NO')
		continue
	if n <= 100:
		if n % 11 == 0:
			print('YES')
		else:
			print('NO')
		continue
	strn = str(n)
	nlen = len(strn)
	arr = [0 for i in range(nlen - 1)]
	tempn = n
	startdivisible = int('1' * (nlen + 1))
	index = -2
	while tempn > 11:
		index += 1
		if startdivisible > tempn:
			startdivisible = startdivisible // 10
			continue
		quot = tempn // startdivisible
		arr[index] = quot
		tempn = tempn % startdivisible
		startdivisible = startdivisible // 10
	if tempn == 0:
		print('YES')
		continue
	neednum = 11 - tempn
	index = -1
	flag = 0
	nlen = nlen - 1
	while index < nlen:
		index += 1
		curval = arr[index]
		if index + 1 == nlen:
			break
		if curval == 0:
			continue
		if curval >= neednum:
			flag = 1
			break
		neednum -= curval
		arr[index + 1] = curval * 10
	if flag == 0:
		print('NO')
	else:
		print('YES')


from sys import stdout, stdin, setrecursionlimit
from io import BytesIO, IOBase
from collections import *
from itertools import *
from bisect import *
from string import *
from queue import *
from heapq import *
from math import *
from re import *
from os import *

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(stdin, stdout) = (IOWrapper(stdin), IOWrapper(stdout))
(graph, mod, szzz) = ({}, 10 ** 9 + 7, lambda : sorted(zzz()))

def getStr():
	return input()

def getInt():
	return int(input())

def listStr():
	return list(input())

def getStrs():
	return input().split()

def isInt(s):
	return '0' <= s[0] <= '9'

def input():
	return stdin.readline().strip()

def zzz():
	return [int(i) for i in input().split()]

def output(answer, end='\n'):
	stdout.write(str(answer) + end)

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)
dx = [-1, 1, 0, 0, 1, -1, 1, -1]
dy = [0, 0, 1, -1, 1, -1, -1, 1]
daysInMounth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
num = getInt()
for _ in range(num):
	n = getInt()
	ans = False
	for i in range(500):
		for j in range(500):
			s = 11 * i + 111 * j
			rem = n - s
			if rem >= 0:
				if rem % 11111 == 0:
					ans = True
					break
				else:
					pass
			else:
				break
		if ans:
			break
	print('YES' if ans else 'NO')


import math
T = int(input())
for _ in range(T):
	k = int(input())
	if k % 11 > int(k // 111):
		print('NO')
	else:
		print('YES')


for each in range(int(input())):
	a = int(input())
	if a % 11 * 111 <= a:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	x = int(input())
	rem = x - x % 11 * 111
	if rem >= 0 and rem % 11 == 0:
		print('YES')
	else:
		print('NO')


for s in [*open(0)][1:]:
	x = int(s)
	print('YNEOS'[all((i % 11 for i in range(x, max(-1, x - 1221), -111)))::2])


import sys, io, os
try:
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
except:
	input = lambda : sys.stdin.readline().encode()
read = lambda : map(int, input().split())
out = []
for _ in range(int(input())):
	n = int(input())
	a = 'NO'
	while n >= 0:
		if n % 11 < 1:
			a = 'YES'
			break
		n -= 111
	out.append(a)
print('\n'.join(out))


dp = [0] * 1100
for i in range(101):
	for j in range(11):
		if j * 111 + i * 11 <= 1099:
			dp[j * 111 + i * 11] = True
		else:
			break
for _ in range(int(input())):
	n = int(input())
	print('YES' if n > 1099 or dp[n] else 'NO')


ans = list(map(int, '0 1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 21 23 24 25 26 27 28 29 30 31 32 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64 65 67 68 69 70 71 72 73 74 75 76 78 79 80 81 82 83 84 85 86 87 89 90 91 92 93 94 95 96 97 98 100 101 102 103 104 105 106 107 108 109 112 113 114 115 116 117 118 119 120 123 124 125 126 127 128 129 130 131 134 135 136 137 138 139 140 141 142 145 146 147 148 149 150 151 152 153 156 157 158 159 160 161 162 163 164 167 168 169 170 171 172 173 174 175 178 179 180 181 182 183 184 185 186 189 190 191 192 193 194 195 196 197 200 201 202 203 204 205 206 207 208 211 212 213 214 215 216 217 218 219 223 224 225 226 227 228 229 230 234 235 236 237 238 239 240 241 245 246 247 248 249 250 251 252 256 257 258 259 260 261 262 263 267 268 269 270 271 272 273 274 278 279 280 281 282 283 284 285 289 290 291 292 293 294 295 296 300 301 302 303 304 305 306 307 311 312 313 314 315 316 317 318 322 323 324 325 326 327 328 329 334 335 336 337 338 339 340 345 346 347 348 349 350 351 356 357 358 359 360 361 362 367 368 369 370 371 372 373 378 379 380 381 382 383 384 389 390 391 392 393 394 395 400 401 402 403 404 405 406 411 412 413 414 415 416 417 422 423 424 425 426 427 428 433 434 435 436 437 438 439 445 446 447 448 449 450 456 457 458 459 460 461 467 468 469 470 471 472 478 479 480 481 482 483 489 490 491 492 493 494 500 501 502 503 504 505 511 512 513 514 515 516 522 523 524 525 526 527 533 534 535 536 537 538 544 545 546 547 548 549 556 557 558 559 560 567 568 569 570 571 578 579 580 581 582 589 590 591 592 593 600 601 602 603 604 611 612 613 614 615 622 623 624 625 626 633 634 635 636 637 644 645 646 647 648 655 656 657 658 659 667 668 669 670 678 679 680 681 689 690 691 692 700 701 702 703 711 712 713 714 722 723 724 725 733 734 735 736 744 745 746 747 755 756 757 758 766 767 768 769 778 779 780 789 790 791 800 801 802 811 812 813 822 823 824 833 834 835 844 845 846 855 856 857 866 867 868 877 878 879 889 890 900 901 911 912 922 923 933 934 944 945 955 956 966 967 977 978 988 989 1000 1011 1022 1033 1044 1055 1066 1077 1088 1099'.split()))
for _ in range(int(input())):
	n = int(input())
	if n in ans:
		print('NO')
	else:
		print('YES')


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	x = n % 11
	if n < 11:
		print('NO')
		continue
	if len(str(n)) == 2:
		if n % 11 != 0:
			print('NO')
			continue
	if x * 111 <= n and (n - x * 111) % 11 == 0:
		print('YES')
	else:
		print('NO')


filling = {}

def solve(n, s):
	if n == 0:
		return True
	if n < 11 or len(s) < 2:
		return False
	if n < int(s) and len(s) == 2:
		return False
	if (n, s) in filling:
		return filling[n, s]
	if n >= int(s):
		filling[n, s] = solve(n - int(s), s) or solve(n, s[:-1])
	else:
		filling[n, s] = solve(n, s[:-1])
	return filling[n, s]
for _ in range(int(input())):
	n = int(input())
	s = '1' * (len(str(n)) + 1)
	if n < 11:
		print('NO')
		continue
	if solve(n, s):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	if n > 1099:
		print('YES')
		continue
	elif n % 11 == 0 or n % 111 == 0:
		print('YES')
		continue
	else:
		for i in range(10):
			n -= 111
			if n < 0:
				print('NO')
				break
			elif n % 11 == 0:
				print('YES')
				break


a = [False] * 1101
i = 11
while i < 1101:
	a[i] = True
	i += 11
i = 111
while i < 1101:
	a[i] = True
	j = i + 11
	while j < 1101:
		a[j] = True
		j += 11
	i += 111
T = int(input())
for t in range(T):
	n = int(input())
	if n >= 1100 or a[n]:
		print('YES')
		continue
	print('NO')


t = int(input())
for test in range(t):
	n = int(input())
	rem = n % 11
	quo = n // 11
	ava = quo / 10
	if ava >= rem:
		print('YES')
	else:
		print('NO')


test_case = int(input())
final_list = ['NO' for i in range(test_case)]
for i in range(test_case):
	n = int(input())
	while n > 0:
		if n % 11 == 0 or n % 111 == 0:
			final_list[i] = 'YES'
			break
		n -= 111
for i in final_list:
	print(i)


def solve(x):
	if 111 * (x % 11) <= x:
		print('YES')
	else:
		print('NO')
T = int(input())
for t in range(T):
	x = int(input())
	solve(x)


from functools import lru_cache

@lru_cache(maxsize=None)
def f(n):
	if n == 0:
		return True
	n -= 1
	e = 1
	while n >= 0:
		e *= 10
		n -= e
		if f(n):
			return True
	return False

def f_big(n):
	return True if n > 10 * 110 else f(n)

def main():
	t = int(input())
	for __ in range(t):
		print('YES' if f_big(int(input())) else 'NO')
main()


from collections import deque, Counter
from collections import defaultdict as dfd
from bisect import bisect, bisect_left
from math import sqrt, gcd, ceil, factorial
from heapq import heapify, heappush, heappop
MOD = 10 ** 9 + 7
inf = float('inf')
ans_ = []

def nin():
	return int(input())

def ninf():
	return int(file.readline())

def st():
	return input().strip()

def stf():
	return file.readline().strip()

def read():
	return list(map(int, input().strip().split()))

def readf():
	return list(map(int, file.readline().strip().split()))

def readfl():
	return list(map(float, input().strip().split()))

def readffl():
	return list(map(float, file.readline().strip().split()))

def solve():
	for _ in range(nin()):
		n = nin()
		fl = 0
		for i in range(12):
			if i * 111 <= n and (n - i * 111) % 11 == 0:
				fl = 1
		if fl:
			ans_.append('YES')
		else:
			ans_.append('NO')
solve()
for i in ans_:
	print(i)


t = int(input())
for iasodkja in range(t):
	n = int(input())
	a = n % 11
	ba = n // 11
	if ba - a * 10 >= 0:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
from heapq import heapify, heappush, heappop, heappushpop
from collections import defaultdict as dd, deque as dq, Counter as C
from bisect import bisect_left as bl, bisect_right as br
from itertools import combinations as cmb, permutations as pmb
from math import factorial as f, ceil, gcd, sqrt, log, inf
mi = lambda : map(int, input().split())
ii = lambda : int(input())
li = lambda : list(map(int, input().split()))
mati = lambda r: [li() for _ in range(r)]
lcm = lambda a, b: a * b // gcd(a, b)
MOD = 10 ** 9 + 7

def soe(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def solve():
	n = ii()
	p = n % 11
	if p * 111 <= n and (n - p * 111) % 11 == 0:
		print('YES')
		return
	print('NO')
for _ in range(ii()):
	solve()


dp = [False] * 1200
dp[0] = True
for i in range(1, 1200):
	if i % 11 == 0:
		dp[i] = True
	if i % 111 == 0:
		dp[i] = True
	if i > 11 and dp[i - 11]:
		dp[i] = True
	if i > 111 and dp[i - 111]:
		dp[i] = True
for _ in range(int(input())):
	N = int(input())
	if N > 1199:
		print('YES')
	elif dp[N]:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	x = int(input())
	while True:
		if x < 0:
			print('NO')
			break
		if x % 111 == 0 or x == 0:
			print('YES')
			break
		else:
			x -= 11


R = lambda : list(map(int, input().split()))
for _ in ' ' * int(input()):
	n = R()[0]
	for y in range(n // 111 + 1):
		x = n - 111 * y
		if x % 11 == 0:
			print('YES')
			break
	else:
		print('NO')


import sys
input = sys.stdin.readline

def main(n):
	t = 0
	if n % 11 == 0:
		print('YES')
		return
	for i in range(int(n / 111)):
		t += 111
		if (n - t) % 11 == 0:
			print('YES')
			return
	print('NO')
for i in range(int(input())):
	n = int(input())
	main(n)


import math
import sys
import collections
import bisect
import time
import random
from itertools import permutations

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	n = int(input())
	rem = n % 11
	ques = n // 11
	if rem * 10 <= ques:
		print('YES')
	else:
		print('NO')


check = [False for i in range(1100)]
check[11] = check[111] = True
for i in range(12, 1100):
	check[i] |= check[i - 11] | check[i - 111]
for _ in range(int(input())):
	x = int(input())
	if x > 1099:
		print('YES')
	else:
		print('YES' if check[x] else 'NO')


for _ in range(int(input())):
	n = int(input())
	if n > 1099:
		print('YES')
		continue
	x = n % 11
	if n < 11:
		print('NO')
		continue
	if len(str(n)) == 2:
		if n % 11 != 0:
			print('NO')
			continue
	if x * 111 <= n and (n - x * 111) % 11 == 0:
		print('YES')
	else:
		print('NO')


import os, sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 998244353
from math import ceil, gcd
from bisect import bisect_right, bisect_left
from _collections import deque
for _ in range(int(input())):
	n = int(input())
	t = n % 11
	if n >= t * 111:
		print('YES')
	else:
		print('NO')


ones = [111111111, 11111111, 1111111, 111111, 11111, 1111, 111, 11]
for _ in range(int(input())):
	n = int(input())
	q = n // 11
	r = n % 11
	if q >= 10 * r:
		print('YES')
	else:
		print('NO')


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	N = int(input())
	(a, d) = divmod(N, 11)
	if d > 0:
		N -= d * 111
		if N >= 0:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	x = int(input())
	print('NO' if x % 11 * 111 > x else 'YES')


def res(n):
	a = n % 11
	if (n - a * 111) % 11 == 0 and a * 111 <= n:
		return True
	return False
t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	if res(n):
		print('YES')
	else:
		print('NO')


t = int(input())
arr = []
for i in range(t):
	arr.append(int(input()))
for i in arr:
	if i >= 111 * (i % 11):
		print('YES')
	else:
		print('NO')


import sys
for _ in range(int(sys.stdin.readline())):
	N = int(sys.stdin.readline())
	temp = N
	if N > 1099:
		print('YES')
	else:
		while N >= 0:
			if N % 11 == 0:
				print('YES')
				break
			N -= 111
		else:
			print('NO')


import sys
from collections import Counter
INP = lambda : sys.stdin.readline().strip()
INT = lambda : int(INP())
MAP = lambda : map(int, INP().split())
ARR = lambda : [int(i) for i in INP().split()]

def JOIN(arr, x=' '):
	return x.join([str(i) for i in arr])

def EXIT(x='NO'):
	print(x)
	exit()
for _ in range(INT()):
	x = INT()
	ans = 'NO'
	while x >= 0:
		if x % 11 == 0:
			ans = 'YES'
			break
		x -= 111
	print(ans)


from sys import stdin

def A():
	t = stdin.readline()
	t = int(t)
	while t:
		t -= 1
		n = int(stdin.readline())
		a = [int(x) for x in stdin.readline().split()]
		a.sort()
		for i in range(1, len(a) - 1):
			if a[i] == (a[i - 1] + a[i + 1]) / 2:
				for j in range(0, len(a)):
					if j == i - 1 or j == i or j == i + 1:
						continue
					if a[j] != (a[i - 1] + a[i + 1]) / 2:
						(a[i], a[j]) = (a[j], a[i])
						break
		for i in a:
			print(i, end=' ')
		print()

def B():
	t = stdin.readline()
	t = int(t)
	while t:
		t -= 1
		n = int(stdin.readline())
		if n % 11 == 0:
			print('YES')
		else:
			a = n % 11
			if n - a * 111 >= 0:
				print('YES')
			else:
				print('NO')

def C():
	t = stdin.readline()
	t = int(t)
	a = [int(x) for x in stdin.readline().split()]
	a.sort()
	a.reverse()
	res = 0
	for i in range(0, len(a)):
		res += a[i]
		if res < 0:
			res = i
			break
	print(res)
B()


import sys
t = int(sys.stdin.readline())
for i in range(t):
	x = int(sys.stdin.readline())
	data = [111 * j for j in range(11)]
	flag = 0
	for item in data:
		if item > x:
			break
		temp = x - item
		if temp % 11 == 0:
			flag = 1
			print('YES')
			break
	if flag:
		continue
	print('NO')


import sys
import math

def check(x):
	return x % 11 <= x // 111

def main():
	stdin = sys.stdin
	n = int(stdin.readline())
	for _ in range(n):
		if check(int(stdin.readline())):
			print('YES')
		else:
			print('NO')
main()

def test_check():
	for x in range(100):
		for y in range(100):
			for z in range(100):
				if not check(x * 1111 + y * 111 + z * 11):
					print(x, y, z)


t = int(input())
import math

def main(n, a, b, c, d):
	if n % a == 0 or n % b == 0 or n % c == 0 or (n % d == 0):
		return 1
	if n >= d:
		if n % d == 0:
			return 1
		for i in range(1, math.ceil(n / d)):
			if main(n - d * i, a, b, c, d):
				return 1
	if n >= c:
		if n % c == 0:
			return 1
		for i in range(1, math.ceil(n / c)):
			if main(n - c * i, a, b, c, d):
				return 1
	if n >= b:
		if n % b == 0:
			return 1
		for i in range(1, math.ceil(n / b)):
			if main(n - b * i, a, b, c, d):
				return 1
	if n >= a:
		if n % a == 0:
			return 1
		else:
			return 0
	return 0
for _ in range(t):
	n = int(input())
	a = 11
	b = 111
	c = 11111
	d = 1111111
	if main(n, a, b, c, d):
		print('YES')
	else:
		print('NO')


for ttt in range(int(input())):
	n = int(input())
	xx = n
	if n < 11:
		print('NO')
		continue
	if n > 1099:
		print('YES')
		continue
	while n >= 11:
		if n % 11 == 0:
			n = n % 11
		else:
			n -= 111
	if n == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	b = 0
	rem = n % 11
	if 111 * rem <= n and (n - 111 * rem) % 11 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	x = int(input())
	y = x % 11
	x = x - y * 111
	if x < 0:
		print('NO')
	elif x % 11 == 0:
		print('YES')
	else:
		print('NO')


import sys
input = lambda : sys.stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	rem = n % 11
	print('YES' if rem == 0 or 111 * rem <= n else 'NO')


for _ in range(int(input())):
	n = int(input())
	flag = False
	while n > 0:
		if n % 11 == 0:
			n //= 11
			flag = True
			break
		else:
			n -= 111
	if n == 0 or flag:
		print('YES')
	else:
		print('NO')


from sys import *
from collections import defaultdict as dd
from math import *
from bisect import *

def sinp():
	return input()

def inp():
	return int(sinp())

def minp():
	return map(int, sinp().split())

def linp():
	return list(minp())

def strl():
	return list(sinp())

def pr(x):
	print(x)
mod = int(1000000000.0 + 7)
for _ in range(inp()):
	x = inp()
	if x // 11 >= 10 * (x % 11):
		pr('YES')
	else:
		pr('NO')


t = int(input())
for i in range(0, t):
	r = 0
	n = int(input())
	p = int(n)
	if n <= 10:
		print('NO')
		continue
	if n % 11 == 0 or n % 111 == 0 or n % 1111 == 0 or (n % 11111 == 0) or (n % 111111 == 0) or (n % 1111111 == 0) or (n % 11111111 == 0) or (n % 111111111 == 0):
		print('YES')
	else:
		while n >= 111:
			n = n - 111
			if n % 11 == 0:
				r = 1
				break
		if r == 1:
			print('YES')
		else:
			print('NO')


def result(x):
	r1 = x - x % 11 * 111
	if r1 >= 0 and r1 % 11 == 0:
		return 'YES'
	else:
		return 'NO'
	return None
t = int(input())
for i in range(0, t):
	x = int(input())
	print(result(x))


inp = int(input())
for _ in range(inp):
	n = int(input())
	if n > 1099:
		print('YES')
	elif n >= 111 * (n % 11):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	x = n % 11
	y = (n - x) // 11 - 9 * x
	if x <= y:
		print('YES')
	else:
		print('NO')


def iHate1111(n):
	a = n % 11
	b = (n - a) / 11 - 10 * a
	if b >= 0 and int(b) == b:
		return 'YES'
	return 'NO'
t = int(input())
for _ in range(t):
	n = int(input())
	print(iHate1111(n))


for _ in range(int(input())):
	n = int(input())
	r = n % 11
	if r * 111 <= n and (n - r * 111) % 11 == 0:
		print('YES')
	else:
		print('NO')


def solve(n: int) -> str:
	for i in range(10000000):
		if n - i * 111 >= 0:
			if (n - i * 111) % 11 == 0:
				return 'YES'
		else:
			break
	return 'NO'
test_cases = int(input())
for _ in range(test_cases):
	n = int(input())
	print(solve(n))


import sys
import math
import collections

def scan(input_type='int'):
	return list(map(int, sys.stdin.readline().strip().split()))

def function(n, i, c, s, a):
	if s < 0:
		return c - 1
	if i == n:
		return c
	if i == n - 1:
		s += a[i]
		if s >= 0:
			return c + 1
		else:
			return c
	if a[i] >= 0:
		return function(n, i + 1, c + 1, s + a[i], a)
	return max(function(n, i + 1, c + 1, s + a[i], a), function(n, i + 1, c, s, a))

def solution():
	for _ in range(int(input())):
		n = int(input())
		if n >= 111 * (n % 11):
			print('YES')
		else:
			print('NO')
solution()


n = int(input())
for i in range(n):
	x = int(input())
	b = x % 11
	a = (x - 111 * b) / 11
	if x == 11 * a + 111 * b and a >= 0 and ((x - 111 * b) % 11 == 0):
		print('YES')
	else:
		print('NO')


s = set()
for i in range(200):
	for j in range(50):
		for k in range(10):
			if 11 * i + 111 * j + 1111 * k <= 1200:
				s.add(11 * i + 111 * j + 1111 * k)
t = int(input())
for _ in range(t):
	n = int(input())
	if n > 1200:
		print('YES')
	elif n in s:
		print('YES')
	else:
		print('NO')


def solve():
	tc = int(input())
	for _ in range(tc):
		n = int(input())
		if n >= 111 * (n % 11):
			print('YES')
		else:
			print('NO')
solve()


from math import *
for _ in range(int(input())):
	n = int(input())
	if n % 11 * 111 <= n:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	if n >= 1111:
		print('YES')
	elif n >= 111 * (n % 11):
		print('YES')
	else:
		print('NO')


from sys import *
input = lambda : stdin.readline()
int_arr = lambda : list(map(int, stdin.readline().strip().split()))
str_arr = lambda : list(map(str, stdin.readline().split()))
get_str = lambda : map(str, stdin.readline().strip().split())
get_int = lambda : map(int, stdin.readline().strip().split())
get_float = lambda : map(float, stdin.readline().strip().split())
mod = 1000000007
setrecursionlimit(1000)
for _ in range(int(input())):
	n = int(input())
	while n >= 0:
		if n % 11 == 0 or n % 111 == 0:
			print('YES')
			break
		n -= 111
	else:
		print('NO')


t = int(input())
for w in range(t):
	x = int(input())
	n = x % 11
	if x < n * 111:
		print('NO')
		continue
	print('YES')


from sys import stdin, stdout, setrecursionlimit
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())
from collections import defaultdict as dd, Counter as C, deque
from math import ceil, gcd, sqrt, factorial, log2, floor
from bisect import bisect_right as br, bisect_left as bl
import heapq
for _ in range(it()):
	n = it()
	b = n % 11
	val = n - b * 111
	if not val % 11 and val >= 0:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	x = int(input())
	if x >= 111 * (x % 11):
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
from math import gcd, sqrt, floor, ceil
input = stdin.readline
PRINT = stdout.write

def list_inp(x):
	return list(map(x, input().split()))

def map_inp(x):
	return map(x, input().split())

def lcm(a, b):
	return a * b / gcd(a, b)
t = int(input())
for i in range(t):
	n = int(input())
	if n >= 111 * (n % 11):
		print('YES')
	else:
		print('NO')


def solve(n):
	k = n % 11
	if n < 11:
		print('NO')
		return
	if n >= 10 and n <= 99:
		if n % 11 != 0:
			print('NO')
			return
	if k * 111 <= n and (n - k * 111) % 11 == 0:
		print('YES')
	else:
		print('NO')
t = int(input())
for _ in range(t):
	n = int(input())
	solve(n)


t = int(input())
for _ in range(t):
	n = int(input())
	d = n % 11
	if d * 111 <= n:
		print('YES')
	else:
		print('NO')


import sys
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
for _ in range(RI()):
	N = RI()
	print('YES' if N >= 111 * (N % 11) else 'NO')


a = [0] * 1200
a[0] = 1
for j in range(1200):
	if a[j]:
		if j + 11 < 1200:
			a[j + 11] = 1
		if j + 111 < 1200:
			a[j + 111] = 1
		if j + 1111 < 1200:
			a[j + 1111] = 1
for i in range(int(input())):
	x = int(input())
	if x < 1200:
		print('YES' if a[x] else 'NO')
	else:
		print('YES')


t = int(input())
for ii in range(t):
	n = int(input())
	m = n % 11
	m *= 111
	if n < m:
		print('NO')
	else:
		print('YES')


t = int(input())
while t:
	t -= 1
	n = int(input())
	if n % 11 == 0:
		print('YES')
	elif n % 11 == 1:
		print('YES' if n >= 111 else 'NO')
	elif n % 11 == 2:
		print('YES' if n >= 222 else 'NO')
	elif n % 11 == 3:
		print('YES' if n >= 333 else 'NO')
	elif n % 11 == 4:
		print('YES' if n >= 444 else 'NO')
	elif n % 11 == 5:
		print('YES' if n >= 555 else 'NO')
	elif n % 11 == 6:
		print('YES' if n >= 666 else 'NO')
	elif n % 11 == 7:
		print('YES' if n >= 777 else 'NO')
	elif n % 11 == 8:
		print('YES' if n >= 888 else 'NO')
	elif n % 11 == 9:
		print('YES' if n >= 999 else 'NO')
	elif n % 11 == 10:
		print('YES' if n >= 1110 else 'NO')


import sys
import math
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2, floor, log
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)
N = 20005

def isPowerOfTwo(x):
	return x and (not x & x - 1)
T = 1
T = int(stdin.readline())
for _ in range(T):
	n = int(stdin.readline())
	y = n % 11
	n -= 110 * y + y
	if n < 0:
		print('NO')
		continue
	if n % 11 == 0:
		print('YES')
	else:
		print('NO')


def solution():
	for t in range(int(input())):
		x = int(input())
		div = [11, 111]
		ans = 0
		if x >= x % div[0] * div[1]:
			print('YES')
		else:
			print('NO')
	return
solution()


dp = [0 for i in range(10000)]
val = [11, 111, 1111, 11111, 111111, 1111111, 11111111, 111111111, 1111111111]
for j in val:
	if j < 10000:
		dp[j] = 1
for i in range(10000):
	if dp[i] == 1:
		for j in val:
			if i + j < 10000:
				dp[i + j] = 1
for _ in range(int(input())):
	n = int(input())
	if n >= 10000:
		print('YES')
	elif dp[n] == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	m = int(input())
	ct = 0
	if m % 11 == 0:
		ct = 1
	elif m % 111 == 0:
		ct = 1
	elif m >= 111 and (m - 111) % 11 == 0:
		ct = 1
	elif m >= 222 and (m - 222) % 11 == 0:
		ct = 1
	elif m >= 333 and (m - 333) % 11 == 0:
		ct = 1
	elif m >= 444 and (m - 444) % 11 == 0:
		ct = 1
	elif m >= 555 and (m - 555) % 11 == 0:
		ct = 1
	elif m >= 666 and (m - 666) % 11 == 0:
		ct = 1
	elif m >= 777 and (m - 777) % 11 == 0:
		ct = 1
	elif m >= 888 and (m - 888) % 11 == 0:
		ct = 1
	elif m >= 999 and (m - 999) % 11 == 0:
		ct = 1
	elif m >= 1110 and (m - 1110) % 11 == 0:
		ct = 1
	if ct == 1:
		print('YES')
	elif m > 1099:
		print('YES')
	else:
		print('NO')


import sys
for _ in range(int(sys.stdin.readline())):
	x = int(sys.stdin.readline())
	data = [i * 111 for i in range(11)]
	flag = 0
	for item in data:
		temp = x - item
		if temp < 0:
			break
		if temp % 11 == 0:
			flag = 1
			break
	print('YES' if flag else 'NO')


def solve(n):
	if n > 1099:
		return True
	while n % 11 != 0:
		n -= 111
	return False if n < 0 else True
num_t = int(input())
sols = []
for x in range(num_t):
	n = int(input())
	r = 'YES' if solve(n) else 'NO'
	sols.append(r)
print(*sols, sep='\n')


for test in range(int(input())):
	n = int(input())
	if n >= 1110:
		print('YES')
	else:
		while n % 11 != 0:
			n -= 111
		if n >= 0:
			print('YES')
		else:
			print('NO')


t = int(input())
for q in range(t):
	num = int(input())
	flag = 0
	while num >= 111:
		if num % 11 == 0:
			flag = 1
			break
		else:
			num -= 111
	if num % 11 == 0:
		flag = 1
	if flag:
		print('YES')
	else:
		print('NO')


tc = int(input())
for _ in range(tc):
	n = int(input())
	can = False
	for i in range(20):
		if n % 11 == 0:
			can = True
		n -= 111
		if n < 0:
			break
	if can:
		print('yes')
	else:
		print('no')


from math import ceil
t = int(input())
for tc in range(1, t + 1):
	x = int(input())
	a = x % 11
	if a == 0 or x - a * 111 >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	b = n % 11
	a = (n - b) // 11 - 10 * b
	print('YES') if a >= 0 else print('NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	for i in range(11):
		if n >= i * 111 and (n - i * 111) % 11 == 0:
			print('YES')
			break
	else:
		print('NO')


for iii in range(int(input())):
	ans = 'NO'
	n = int(input())
	for i in range(11):
		p = (n - i) % 11
		if p == 0:
			p1 = (n - i) // 11 - 10 * i
			if p1 >= 0:
				ans = 'YES'
				break
	print(ans)


theta = 0
import sys
theta = 0
import io
theta = 0
from sys import stdin, stdout
theta = 0
input = sys.stdin.readline
theta = 0
theta = 0
theta = 0
t = 1
theta = 0
t = int(input())
theta = 0
for i in range(t):
	theta = 0
	n = int(input())
	theta = 0
	div = n // 11
	theta = 0
	rem = n % 11
	theta = 0
	if rem <= div // 10:
		theta = 0
		ans = 1
		theta = 0
	else:
		theta = 0
		ans = 0
		theta = 0
	theta = 0
	if ans:
		theta = 0
		print('YES')
		theta = 0
	else:
		theta = 0
		print('NO')
		theta = 0


t = int(input())
for tc in range(t):
	x = int(input())
	if x >= x % 11 * 111:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	t -= 1
	x = int(input())
	if x % 11 == 0:
		print('YES')
	elif x % 111 == 0:
		print('YES')
	else:
		temp = 0
		while x > 111:
			x -= 111
			if x % 11 == 0:
				temp = 1
				break
		if temp == 1:
			print('YES')
		else:
			print('NO')


strng = lambda : input()
inp = lambda : int(input())
mul = lambda : map(int, input().split())
jn = lambda x, l: x.join(map(str, l))
strlst = lambda : list(input())
lst = lambda : list(map(int, input().split()))
dd = lambda : defaultdict(lambda : 0)
import sys
input = sys.stdin.readline
from collections import defaultdict
from math import ceil, log, floor, sqrt, gcd, log10
for _ in range(inp()):
	n = inp()
	m = n % 11
	n -= m * 111
	if n >= 0 and n % 11 == 0:
		print('YES')
		continue
	print('NO')


from collections import Counter, defaultdict, OrderedDict, deque
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from typing import List
import itertools
import math
import heapq
import string
import random
(MIN, MAX, MOD) = (-1061109567, 1061109567, 1000000007)
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())
for _ in range(N()):
	n = N()
	if n >= 1111:
		print('YES')
		continue
	f = False
	for y in range(11):
		p = 111 * y
		if n - p >= 0 and (n - p) % 11 == 0:
			f = True
	print('YES' if f else 'NO')


import os
import sys
from io import BytesIO, IOBase
ide = False
has_tc = True

def main():
	if ide:
		(sys.stdin, sys.stdout) = (open('../input.txt', 'r'), open('../output.txt', 'w'))
	if has_tc:
		tc = int(input())
		for _ in range(tc):
			solve()
	else:
		solve()

def solve():
	n = int(input())
	if n == 0:
		print('NO')
		return
	if n > 11 * 111 - 11 - 111:
		print('YES')
		return
	for i in range(0, n // 111 + 1):
		if (n - i) % 11 == 0:
			print('YES')
			return
	print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
lin = lambda type: list(map(type, input().split()))
main()


for _ in range(int(input())):
	n = int(input())
	if n / 11 >= 10 * (n % 11):
		print('YES')
	else:
		print('NO')


t = int(input())
a = []

def kq(a):
	ans = 0
	if a > 11 * 111 + 11 + 111:
		print('YES')
	else:
		while a >= 0:
			if a % 11 == 0:
				ans = 1
				break
			a -= 111
		print('YES') if ans == 1 else print('NO')
for i in range(t):
	a.append(int(input()))
for i in a:
	kq(i)


from sys import stdin
a = [11, 111, 1111, 11111, 111111, 1111111, 11111111]
for _ in range(int(stdin.readline())):
	n = int(input())
	res = 'NO'
	for i in a:
		if n % i == 0:
			res = 'YES'
	if res == 'YES':
		print(res)
		continue
	while n > 0:
		n -= 11
		for i in a:
			if n % i == 0:
				res = 'YES'
		if res == 'YES':
			break
	print(res)


MAX = 111 * 11 - 11 - 111
pc = set(filter(lambda x: 0 < x < 111 * 11 - 11 - 111, [a * 11 + b * 111 for a in range(100) for b in range(100)]))
t = int(input())
for _ in range(t):
	x = int(input())
	if x > MAX or x in pc:
		print('YES')
	else:
		print('NO')


t = int(input())

def solve(x):
	div = x % 11
	if div == 0:
		return 'YES'
	dev = x // 111
	if dev >= div:
		return 'YES'
	else:
		return 'NO'
for _ in range(t):
	x = int(input())
	print(solve(x))


def decomposition(n):
	if n % 11 == 0 or n % 111 == 0:
		return 'YES'
	remainder = n % 11
	subpart = n - remainder * 111
	if subpart > 0 and subpart % 11 == 0:
		return 'YES'
	return 'NO'
results = []
for _ in range(int(input().strip())):
	test_data = int(input())
	results.append(decomposition(test_data))
print('\n'.join(results))


import random
import math
from collections import defaultdict
import itertools
from sys import stdin, stdout
import sys
import operator

def main():
	z = ''
	for _ in range(int(stdin.readline())):
		n = int(input())
		flag = 0
		if n % 111 == 0:
			flag = 1
		else:
			while n > 0:
				if n % 11 == 0:
					flag = 1
					break
				n -= 111
		if flag == 1:
			print('YES')
		else:
			print('NO')
main()


import os
import sys
from io import BytesIO, IOBase
_print = print
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def inp():
	return sys.stdin.readline().rstrip()

def mpint():
	return map(int, inp().split(' '))

def itg():
	return int(inp())

def extended_gcd(a, b):
	(s, old_s) = (0, 1)
	(r, old_r) = (b, a)
	while r:
		q = old_r // r
		(old_r, r) = (r, old_r - q * r)
		(old_s, s) = (s, old_s - q * s)
	return (old_r, old_s, (old_r - old_s * a) // b if b else 0)

def linear_congruence(a, m, r):
	return extended_gcd(a, m)[1] * r % m

def solve():
	n = itg()
	x = linear_congruence(111, 11, n)
	by = n - 111 * x
	return by >= 0 == by % 11

def main():
	for _ in range(itg()):
		print('YES' if solve() else 'NO')
DEBUG = 0
URL = 'https://codeforces.com/contest/1526/problem/B'
if DEBUG == 1:
	import requests
	from ACgenerator.Y_Test_Case_Runner import TestCaseRunner
	runner = TestCaseRunner(main, URL)
	inp = runner.input_stream
	print = runner.output_stream
	runner.checking()
else:
	if DEBUG != 2:
		_print = lambda *args, **kwargs: ...
		(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	if DEBUG:

		def print(*args, **kwargs):
			_print(*args, **kwargs)
			sys.stdout.flush()
	main()


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	if n >= 111 * (n % 11):
		print('YES')
	else:
		print('NO')


check = []
for i in range(0, 1111):
	check.append(False)
for p in range(1, 1111):
	if p % 11 == 0 or p % 111 == 0:
		check[p] = True
	elif p > 11 and check[p - 11]:
		check[p] = True
	elif p > 111 and check[p - 111]:
		check[p] = True
t = int(input())
while t > 0:
	t -= 1
	x = int(input())
	if x >= 1111:
		print('YES')
	elif check[x]:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	u = 0
	x = int(input())
	for j in range(x // 111 + 1):
		if (x - 111 * j) % 11 == 0:
			print('YES')
			u = 1
			break
	if u == 0:
		print('NO')


for t in range(int(input())):
	n = int(input())
	good = False
	for i in range(100):
		if n < 0:
			break
		if n % 11 == 0:
			good = True
		n -= 111
	if good:
		print('YES')
	else:
		print('NO')


def solve():
	if X < len(a111_b11):
		return 'YES' if a111_b11[X] else 'NO'
	return 'YES'

def a111_b11_nos():
	N = 111 * 11 - 111 - 11
	a111_b11 = [False] * (N + 1)
	a111_b11[0] = True
	for ones in (111, 11):
		for i in range(ones, N + 1):
			a111_b11[i] |= a111_b11[i - ones]
	return a111_b11
a111_b11 = a111_b11_nos()
test_cases = int(input())
for test_case in range(test_cases):
	X = int(input())
	print(solve())


for i in range(int(input())):
	x = int(input())
	c = x // 11
	d = x % 11
	if c // 10 >= d:
		print('YES')
	else:
		print('NO')


l = [False for i in range(1100)]
ini = 0
while ini < 1100:
	for j in range(ini, 1100, 11):
		l[j] = True
	ini = ini + 111

def f(x, l):
	if x >= 1100:
		return 'YES'
	elif l[x]:
		return 'YES'
	else:
		return 'NO'
t = int(input())
i = 0
while i != t:
	i = i + 1
	x = int(input())
	print(f(x, l))


for _ in range(int(input())):
	n = int(input())
	if n >= 1100:
		print('YES')
	else:
		a = n // 11
		b = n % 11
		if b == 0:
			print('YES')
		elif a >= 10 and b * 10 <= a:
			print('YES')
		else:
			print('NO')


t = int(input())
const = 1099
for i in range(t):
	n = int(input())
	contingency = 1
	if n > const:
		print('YES')
	else:
		while n > 0:
			if n % 11 == 0:
				contingency -= 1
				break
			n -= 111
		print('YES' if n == 0 or contingency == 0 else 'NO')


def f(n):
	if n < 11 and n != 0:
		return -1
	else:
		s = str(n)
		p = int('1' * len(s))
		if p > n:
			p = int('1' * (len(s) - 1))
		n -= p
		if n == 0:
			return 1
		else:
			return f(n)
for _ in range(int(input())):
	n = int(input())
	if n >= 1110:
		print('YES')
	elif (n - 11) // 111 >= n % 11:
		print('YES')
	elif n % 11 == 0 or n % 111 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	n = int(input())
	if n % 11 * 111 <= n:
		print('YES')
	else:
		print('NO')
	t -= 1


import sys
import collections
import math
inf = sys.maxsize

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
mod = 1000000007
for _ in range(int(input())):
	n = int(input())
	remainder = n % 11
	quotient = n // 11
	print('YES') if quotient >= 10 * remainder else print('NO')


t = int(input())

def kek(num):
	for j in range(num // 111 + 1):
		if (num - 111 * j) % 11 == 0:
			return True
	return False
for _ in range(t):
	num = int(input())
	if kek(num):
		print('YES')
	else:
		print('NO')


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	t = int(input())
	for _ in range(t):
		x = int(input())
		(q, r) = (x // 11, x % 11)
		while r != 0 and q != 0:
			t = min(r, q // 10)
			r -= t
			q = t
		print('NO' if r else 'YES')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from math import *
t = int(input())
for i in range(t):
	x = int(input())
	ans = 'NO'
	if x >= 1221:
		ans = 'YES'
	else:
		y = x // 111
		z = x % 11
		if z <= y:
			ans = 'YES'
	print(ans)


list_ans = []
for _ in range(int(input())):
	s = input()
	if len(s) >= 4 and int(s) not in [1000, 1011, 1022, 1033, 1044, 1055, 1066, 1077, 1088, 1099]:
		list_ans.append('YES')
	else:
		x = int(s)
		while x >= 0:
			if x % 11 == 0:
				list_ans.append('YES')
				break
			x -= 111
		else:
			list_ans.append('NO')
print(*list_ans, sep='\n')


def judge(i):
	q = int(i / 11)
	r = i - 11 * q
	if i >= 111 * r:
		return 'YES'
	else:
		return 'NO'
n = int(input())
lst = []
for i in range(n):
	k = int(input())
	lst.append(k)
for i in lst:
	print(judge(i))


tests = int(input())
answers = []

def solve(n):
	if n % 11 * 111 <= n:
		return 'YES'
	return 'NO'
while tests > 0:
	answers.append(solve(int(input())))
	tests -= 1
for i in answers:
	print(i)


def div2B723(n):
	if n == 0:
		return 'NO'
	if n > 1099:
		return 'YES'
	lt = n // 111
	for i in range(0, lt + 1):
		if (n - i) % 11 == 0:
			return 'YES'
	return 'NO'
t = int(input())
for _ in range(t):
	print(div2B723(int(input())))


t = int(input())
for T in range(t):
	n = int(input())
	val = n % 11 * 111
	ans = 'YES'
	if val > n:
		ans = 'NO'
	print(ans)


import os
import sys
from io import BytesIO, IOBase
from collections import deque

def main():
	for _ in range(int(input())):
		x = int(input())
		b = x % 11
		a = x - 111 * b
		if a >= 0:
			if a % 11:
				print('NO')
			else:
				print('YES')
		else:
			print('NO')

def nouse0():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse1():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse2():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def nouse3():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse4():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse5():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
main()


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	rem = n % 11
	if rem * 111 <= n and (n - rem * 111) % 11 == 0:
		print('YES')
	else:
		print('NO')


import sys
from functools import lru_cache
from itertools import permutations
input = sys.stdin.readline
M = 10 ** 9 + 7

@lru_cache(None)
def get(x):
	if x == 0:
		return True
	return False
T = int(input())
for _ in range(T):
	x = int(input())
	if x > 1099:
		print('YES')
	else:
		f = False
		for i in range(x):
			if x < i * 111:
				break
			if (x - i * 111) % 11 == 0:
				f = True
				break
		if f:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	x = int(input())
	a = x // 11
	b = 10 * (x % 11)
	if a >= b:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	if 10 * (n % 11) <= n // 11:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	for i in range(n // 111 + 1):
		val = n - 111 * i
		if val % 11 == 0:
			print('YES')
			break
	else:
		print('NO')


for t in range(int(input())):
	x = int(input())
	possible = False
	for p in range(0, x // 111 + 1):
		if (x - p * 111) % 11 == 0:
			possible = True
			break
	print('YES' if possible else 'NO')


for s in [*open(0)][1:]:
	x = int(s)
	print('YNEOS'[x < x % 11 * 111::2])


t = int(input())
for _ in range(t):
	n = int(input())
	if n >= 1110:
		print('YES')
		continue
	if n % 111 == 0 or n % 11 == 0 or 111 * (n % 11) < n:
		print('YES')
	else:
		print('NO')


def divideBy11(num):
	res = 111 * (num % 11)
	if num >= 111 * (num % 11):
		return 'YES'
	return 'NO'
testcases = int(input())
while testcases:
	input11 = int(input())
	ans = divideBy11(input11)
	print(ans)
	testcases -= 1


t = int(input())
while t:
	x = int(input())
	temp = x - x % 11 * 111
	if temp >= 0 and temp % 11 == 0:
		print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())
for i in range(t):
	x = input()
	n = ''
	for j in range(len(x)):
		n += '1'
	n = int(n)
	check = False
	while n != 1 and check == False:
		k = int(x)
		c = int(n)
		while c != 1:
			k = k % c
			c -= 1
			c /= 10
		if k == 0:
			check = True
		else:
			n -= 1
			n /= 10
	if check == False:
		x = int(x)
		a = 111
		while a < x:
			c = x - a
			if c % 11 == 0:
				print('yes')
				break
			else:
				a += 111
		if a > x:
			print('no')
	else:
		print('yes')