#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll mod_inv(ll a,ll p)
{
    ll i;
    for(i=0;i<p;i++)
    {
        ll flag=(a*i)%p;
        if(flag==1)
        break;
    }
    return i<0?i+p:i;
}
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        ll x;
        cin >> x;
        ll temp=x%111;
        ll a=temp*mod_inv(11,111)%111;
        ll b=x-(a*11);
        if(b>=0 && b%111==0)
        cout<<"YES\n";
        else
        cout<<"NO\n";
    }
}