#include <bits/stdc++.h>
using namespace std;

#define fo(a, b, c) for(int(a) = (b); (a) < (c); (a)++)
#define rev(a, b, c) for(int(a) = b; a >= c; a--)
#define pb(a) push_back(a)
#define int long long
#define umii unordered_map<int, int>
#define vi vector<int>
#define endl "\n"
#define mem(a,b) memset(a,(b),sizeof(a))
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define YES(b) if(b) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define CASE(t, a) cout<<"Case #"<<t<<":"<<" "<<a<<endl;
const int M = 1000000007;

void sieve(int n)
{
    bool prime[n + 1];  
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1] = false;
    for (int p = 2; p * p <= n; p++) {
    // NOTE: Prime numbers greater than sqrt(n) are automatically found by
    // imposing p*p <= n. Change the range of p only if needed for a specific problem

        if (prime[p] == true) {
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
}

signed main() {
    fastio;

    /*
     COMMENT OUT BEOFRE SUBMISSION
     */
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    set<int> good;
    fo(x, 1, 1100)
        fo(i, 0, 11)
            if((x - 111 * i) >= 0 && (x - 111 * i) % 11 == 0)
                good.insert(x);

    int T = 1;
    cin >> T;
    fo(t, 1, T + 1) {
        int x;
        cin >> x;

        YES(!(good.find(x) == good.end()) || x >= 1100);
    }

    // cout << reduce(1111);

    return 0; 
}