#include<bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define F first
#define S second

using namespace std;

typedef long long int ll;

void solve()
{
	int a[] = {
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
	};
//	{
//		int cnt = 0;
//		for(int i = 1; i <= 3000; i++)
//		{
//			for(int j = 0; j < 200; j++)
//			{
//				for(int k = 0; k < 200; k++)
//				{
//					for(int l = 0; l < 100; l++)
//					{
//						if(11*j + 111*k + 1111 * l == i) 
//						{
//							goto aa;
//						}
//					}
//					
//				}
//			}
//			cout << i << ",\n";
//			aa:;
//		}
////		cout << cnt;
//	}
	int n;
	cin >> n;
	for(auto i : a) if(i == n) {
		cout << "NO\n";
		return;
	}
	cout << "YES\n";
//	int n = s.size();
//	if(n == 1) cout << "NO\n";
//	else if(n == 2)
//	{
//		if(s[0] == s[1]) cout << "YES\n";
//		else cout << "NO\n";
//	}
//	else if(n == 3)
//	{
//		int x = stoi(s);
//		for(int i = 0; i <= 100; i++)
//		{
//			for(int j = 0; j < 10; j++)
//			{
//				if(i * 11 + j*111 == x)
//				{
//					cout << "YES\n";
//					return;
//				}
//			}
//		}
//		cout << "NO\n";
//	}
//	else if(s[n - 1] == s[n - 2])
//	{
//		char c = s[0];
//		for(int i = 1; i < n; i++)
//		{
//			if(c <= s[i])
//			{
//				c = s[i];
//			}
//			else
//			{
//				cout << "NO\n";
//				return;
//			}
//		}
//		cout << "YES\n";
//	}
//	else cout << "YES\n";
}

int main()
{
	
	FAST_IO
	int t = 1;
	cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}
