#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <string.h>
#include <map>
#include <unordered_map>
#include <stdlib.h>
#include <time.h>
#include <vector>
#include <deque>
#define YES "YES"
#define NO "NO"
#define INF 0x3f3f3f3f
#define FAST ios::sync_with_stdio(false)
#define ll long long
#define pb push_back
#define endl '\n'
using namespace std;

int main(){
    int t;
    cin>>t;
    while(t--){
        int x;
        cin>>x;
        int t=x%11;
        
        if(t*111<=x){
            cout<<YES<<endl;
        }
        else{
            cout<<NO<<endl;
        }
    }
}
