#include<bits/stdc++.h>
#define PI 3.14159265358979323846  /* pi */
#define ll long long
#define pb push_back
#define mkp make_pair
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define zer(dp) memset(dp,0,sizeof dp)
#define all(x) x.begin(),x.end()
using namespace std;
void solve()
{
ll testcases;
//testcases=1;
cin>>testcases;
for(int tcc=0;tcc<testcases;tcc++)
{      
ll sum=0,flag=0,ans=0;
ll i,j,k,x,y,z;
ll n,m,l,r,p,t,q;
cin>>n;
//ll a[n]; for(i=0;i<n;i++){ cin>>a[i]; }	
for(i=0;i*111<=n;i++)
{
	if((n-i*111)%11==0)
	{
		flag=1;
		break;
	}
}
cout<<(flag==1?"YES":"NO");
cout<<"\n";
}	
}
int main()
{
fastio;
solve();
return 0;
}
