#include <bits/stdc++.h>
using namespace std;
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define debugg(x) cout<<#x<<'='<<x<<endl;
#define debug1(x,y,z) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<endl;
#define debug cout<<endl<<"********"<<endl;
#define ll long long
#define ull unsigned long long
#define ding cerr<<endl<<"Time: "<<(clock()*1000./CLOCKS_PER_SEC)<<" ms"<<endl;
#define ld long double 
#define itn int
#define pi (int)(3.1415926536)
#define pii pair<int,int>
#define rep(I, A, B) for (int I = (A); I <= (B); ++I)
#define dwn(I, A, B) for (int I = (A); I >= (B); --I)
#define repp(i,a,b) for(int i=(a);i<(b);i++)
#define mod (ll)(1e9+7)
#define mod1 (ll)(49993)
#define int ll
void fre(){
    freopen("test.in","r",stdin);
    freopen("test.out","w",stdout);
}
void fc(){fclose(stdin);fclose(stdout);}
inline ll ccin(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void cou(ll x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) cou(x/10);
    putchar(x%10+'0');
}



const int maxn=1e5+10;
const ll inf=1e16;
const int maxm=5e5+10;


int n,t;
int x1,y;
ll gcd(ll a,ll b){while(b^=a^=b^=a%=b);return a;}
void exgcd(ll a,ll b){
    if(!b){x1=1;y=0;return;}
    exgcd(b,a%b);
    ll tmp=x1;x1=y;y=tmp-a/b*y;
}
signed main(){
    ios;//fre();
    cin>>t;
    exgcd(11,111);
    //debugg(x1);
    //debugg(y);
    while(t--){
        cin>>n;
        ll now1=x1*n,now2=y*n;
        ll now3=(now1%111+111)%111;
        ll now4=n-now3*11;
  //      debugg(now3);
//        debugg(now4);
        if(now3>=0&&now4>=0) cout<<"YES\n";
        else cout<<"NO\n";

    }
    ding;return 0;
}