#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);//freopen("out.out","w",stdout);//freopen("consonant.in","r",stdin);
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define  mpp make_pair
#define ff first
#define ss second

using namespace std;


int main()
{
    IO;

    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        if ( (n%11) <= (n/111) )
            cout<<"YES\n";
        else
            cout<<"NO\n";
    }

    return 0;
}
