#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include<map>
#include <set>
#include <string>
using namespace std;
#define ll long long

int main()
{
    int t;
    cin >> t;
    for (int g = 0; g < t; ++g)
    {
        ll n;
        cin >> n;
        while (n != 0)
        {
            if (n % 11 == 0)
                break;
            if (n % 111 == 0)
                break;
            if (n % 1111 == 0)
                break;
            if (n % 11111 == 0)
                break;
            if (n % 11111 == 0)
                break;
            if (n % 111111 == 0)
                break;
            if (n % 111111 == 0)
                break;
            if (n % 1111111 == 0)
                break;
            n -= 11;
        }
        if (n > 0)
                cout << "YES" << endl;
            else
                cout << "NO" << endl;
    }
    return 0;
}