#include<bits/stdc++.h>

using namespace std;



#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define nline "\n"
//#define pb push_back
//#define ppb pop_back
//#define mp make_pair
//#define ff first
//#define ss second
#define PI 3.141592653589793238462
//#define set_bits __builtin_popcountll
//#define sz(x) ((int)(x).size())
//#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
bool isValid(ll arr[], ll n, ll q, ll total){
	ll count=0;
	ll time=0;
	for(ll i=0;i<n;i++){
		ll j=1;
		time=0;
		while(1){
          time+=j*arr[i];
          j++;
      
          if(time>total)
          	break;
           count++;
		}
	}
	return count>=q;
}
ll sum(ll n,ll G){
	//return n*(n+1)/2;
	ll s=0;
	for(ll i=n;i<G;i++){
		s+=i;
		if(G==s)
			return 1;
	}
	return -1;

}
ll sum2(ll n){
	return n*(n+1)/2;
}
int main(){
	  #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
  freopen("Error.txt","w",stderr);
 freopen("output.txt","w",stdout);
    #endif
 fastio();
int t;

cin>>t;
ll c=1;
while(t--){
ll n;
    cin>>n;
    /*ll arr[]={11,111,1111,11111,111111,1111111,11111111,111111111};
    bool f=true;
    while(n>0){
        for(ll i=0;i<7;i++){
            if(arr[i]<n && arr[i+1]>=n){
                n-=arr[i];
                debug(arr[i]);
                break;
            }
                
    }
}
    if(n==0)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;*/
    bool f=false;
    ll rem=n%11;
    if(rem*111<=n && (n-rem*111)%11==0){
    	f=true;
    }
    if(f)
    	cout<<"YES"<<endl;
    else
    	cout<<"NO"<<endl;

	
}
}
	










