#include <bits/stdc++.h>
using namespace std;
#define ll  long long 
 
int main()
{ 
      ll t,m,i,j,k,ct,c,b,r,l,x=0;
      ll n;c=0;
    cin>>t;
   
    while(t--)
    {   cin>>n;
    if(n%11==0)
    cout<<"YES"<<endl;
    else{
        m=n%11;
        m=m*111;
        if((n-m)%11==0&&n-m>=0)
        cout<<"YES"<<endl;
        else
        cout<<"NO"<<endl;
    }
    }
    return 0;
}