#include <bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double

#define MOD 1000000007
using namespace std;

int main() {
    fastIO;
    int t;
    cin >> t;
    
    while (t--) {
        int x;
        cin >> x;
        bool flag = false;
        
        for (int i = 0; i <= 11; i++) {
            if (x < 0) break;
            if (x % 11 == 0) flag = true;
            x -= 111;
        }
        if (flag) cout << "YES\n";
        else cout << "NO\n";
        
    }
}

