#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll gcd(ll a,ll b){
    while(b!=0){
        ll res = a%b;
        a = b;
        b = res;
    }
    return a;
}

void solve(ll cs){
    ll n, i=0;
    cin >> n;
    while(n>0 and i<10){
        if(n%11==0) break;
        else n-=111;
        i++;
    }
    if(n>=0) cout << "YES\n";
    else cout << "NO\n";
}

int main(){
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll t,cs=0;
    //t=1;
    cin >> t;
    while(t--){
        solve(++cs);
    }

}

