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

#define Int long long

const int mxN = 2e5 + 5;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    cin >> t;
    while(t--){
        Int n;
        cin >> n;
        while(n % 11 != 0 && n > 10)n -= 111;
        if(n >= 0 && n % 11 == 0)cout << "YES" << endl;
        else cout << "NO" << endl;
       }
}