/**
 *  author: souravrax
 *  created: 28.05.2021 20:39:12
**/
#include <bits/stdc++.h>
using namespace std;

#define all(x) begin(x), end(x)
#define len(x) int((x).size())
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> 
ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#ifdef LOCAL
#define dbg(...) cerr << "[ " << #__VA_ARGS__ << " ]:", dbg_out(__VA_ARGS__)
#else
#define dbg(...) (void)0x30
#endif
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
using vvi = vector<vector<int>>;
using t3 = tuple<int, int, int>;

vector<int> have = {
    11,
    111,
    1111,
    11111,
    111111,
    1111111,
    11111111
};

map<int, bool> mp[8];

bool dp(int n, int now) {
    dbg(n, now);
    if (n == 0) return now == 0;
    if (mp[n].count(now)) return mp[n][now];
    bool ans = false;
    if (have[n - 1] <= now) ans = dp(n, now - have[n - 1]) || dp(n - 1, now);
    else ans = dp(n - 1, now);
    return mp[n][now] = ans;
}

void solve() {
    int n;
    cin >> n;
    cout << (dp(7, n) ? "YES" : "NO") << '\n';
}

int32_t main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int tt = 1;
    cin >> tt;
    for (int t = 1; t <= tt; t++) {
        solve();
    }
}

