#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double long ld;
#define eb emplace_back
bool is_sqr(int x){ int u = lround(sqrt(x));return x == u*u;}
ll gcd(ll a, ll b) {while(b) {a %= b; swap(a, b);} return a;}
void solve() {
    int x;
    cin >> x;
    if (x%11==0)cout << "YES";
    else{
        int r = x%11;
        if (x - r * 111 >= 0)cout << "YES";
        else cout << "NO";
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
        cout << "\n";
    }
    return 0;
}
