#include <iostream>
#include <string.h>
#include <bits/stdc++.h>
using namespace std;
int main() {
    int t;
    cin >> t;
    while(t--) {
        int x;
        cin >> x;
        bool isPossible = false;
        for (int i = 0; i < 11; i++) {
            if (111*i <= x && (x - 111*i)%11 == 0) {
                isPossible = true;
            }
        }
        if(isPossible) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}
  			   		 		 		   		 	     		