#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e8+7;
const int mod=1e9+7;
#define low(i) i&-i;
#define js ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
inline ll read() { ll s = 0, w = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') w = -1; for (; isdigit(ch); ch = getchar())    s = (s << 1) + (s << 3) + (ch ^ 48); return s * w; }
inline void write(ll x) { if (!x) { putchar('0'); return; } char F[40]; ll tmp = x > 0 ? x : -x; if (x < 0)putchar('-');    int cnt = 0;    while (tmp > 0) { F[cnt++] = tmp % 10 + '0';        tmp /= 10; }    while (cnt > 0)putchar(F[--cnt]); }

void solve(){
    int x;
    x=read();
    if(x>1099) puts("YES");
    else{
        int flag=1;
        for(int i=0;i<=10&&flag;i++)
        for(int j=0;j<=100&&flag;j++){
            int sum=i*111+j*11;
            if(sum==x){
                flag=0;
            }
        }
        if(flag)
        puts("NO");
        else
        puts("YES");
    }
}
int main()  
{  
    int T = read();   for(int i=0;i<T;i++)
    solve();
    return 0;
}