#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define scanVec(vec) for(int never = 0; never < vec.size(); never++){ cin>>vec[never];}
#define printVec(vec) for(int never = 0; never < vec.size(); never++){ cout<<vec[never]<<" ";} cout<<endl;
#define S second
#define F first
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
const int  MOD = 1e9 + 7;
const int  N = 1e6 + 7;



void solve() {
    int n;
    cin >> n;
    int b = n%11;
    int a1 = n - 111*b;
    if(a1 < 0) {
        cout << "NO" << endl;
        return;
    }

    // cout << b << a1 << endl;
    if(a1%11 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

int main() {    
    ios::sync_with_stdio(0);  cin.tie(0); cout.tie(0); 

    int t;
    t = 1;
    cin >> t;
    while(t--) {
        solve();
    }
    
    return 0;
}