#include <bits/stdc++.h>
#define Assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define endl '\n'
#define sz(a) (int)(a).size()
#define File freopen("string.in","r",stdin); freopen("string.out","w",stdout);
int dx[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
int dy[] = { -1, 0, 1, 0, 1, -1, -1, 1 };
const int N = 1e6+ 5, oo = 1e9, mod = 1e9 + 7;
const double pi = acos(-1);
using namespace std;

map<int, bool> dp;

bool solve(int n)
{
    if(n < 0) return false;
    if(!n || n % 11 == 0) return true;
    if(dp.find(n) != dp.end()) return dp[n];
    bool ret = false;
    ret |= solve(n - 111);
    return dp[n] = ret;
}

int main()
{
    Assem99
    int t; cin>>t;
    while(t--)
    {
        int n; cin>>n;
        cout<<(solve(n) || n > 1e5? "YES" : "NO")<<endl;
    }


    return 0;
}