#include <bits/stdc++.h>
using namespace std;
typedef long long                                    ll;
typedef vector<int>                                  vi;
typedef vector<int, int>                             vii;
typedef pair<int, int>                               pii;
#define rep(i,a,b)                                   for(int i = a; i <= b; i++)
#define rrep(i,a,b)                                  for(int i = a; i >= b; i--)
#define trav(it,v)                                   for(auto it = v.begin(); it!= v.end(); it++)
#define pb                                           push_back
#define popb                                         pop_back  
#define mkp                                          make_pair
#define sz(x)                                        x.size()
#define fr                                           first
#define sc                                           second

const int M = 1e9+7;
const ll INF = 1e18;

ll biex(ll a, ll b){
    if(b==0){
        return 1;
    }
    ll ans = biex(a,b/2);
    ans = ans*ans;
    if(b&1){
        return ans*b;
    }
    else{
        return ans;
    }
}

void solve(){
    int x;
    cin >> x;
    rep(c,0,10){
        if(x>=111*c && (x-111*c)%11==0){
            cout << "YES\n";
            return;
        }
    }
    cout << "NO\n";
    return;
}


int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

    int t = 1;
    cin >> t;
    rep(i,1,t){
        solve();
    }
    return 0;
}