import std.stdio;
import std.ascii;
import core.stdc.stdio;

int main()
{
    int t = readInt!int;
    while (t--)
    {
        long x = readInt!long;
        long m111 = 0;
        bool can = false;
        int maxrep = 20;
        int i = 0;
        while (m111 <= x && i < maxrep)
        {
            if ((x - m111) % 11 == 0)
            {
                can = true;
                break;
            }
            m111 += 111;
            i++;
        }
        if (can) writeln("YES"); else writeln("NO");
    }
    return 0;
}






/* INPUT ROUTINES */
int currChar;
static this()
{
    currChar = getchar();
}
char topChar()
{
    return cast(char) currChar;
}
void popChar()
{
    currChar = getchar();
}
auto readInt(T)()
{
    T num = 0;
    int sgn = 0;
    while (topChar.isWhite) popChar;
    while (topChar == '-' || topChar == '+') { sgn ^= (topChar == '-'); popChar; }
    while (topChar.isDigit) { num *= 10; num += (topChar - '0'); popChar; }
    if (sgn) return -num; return num;
}
string readString()
{
    string res = "";
    while (topChar.isWhite) popChar;
    while (!topChar.isWhite) { res ~= topChar; popChar; }
    return res;
}
