#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define ll long long
#define mod 1000000007
#define INFll_MAX
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define sp " "
ll mpow(ll a, ll b){
    if(!b)
        return 1;
    ll temp = mpow(a, b/2);
    temp = (temp * temp);
    if(b%2)
        return (a * temp);
    return temp%mod;
}
ll n;
void solve(){
    cin>>n;
    for(int i=n/11;i>=0;i--){
        int y=n-11*i;
        if(y%111==0 && 11*i+y==n){
            cout<<"YES\n";
            return;
        }
    }
    cout<<"NO\n";
}
int main()
{
        ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
 
freopen("input.txt", "r", stdin);
 
freopen("output1.txt", "w", stdout);
 
#endif // ONLINE_JUDGE
    int t=1;
    cin>>t;
    while (t--)
    {
       solve();
    }
    
    return 0;

}
