#include<bits/stdc++.h>
using namespace std;

int main()
{
    int test;
    cin>>test;
    
    while(test--)
    {
    	int n;
    	cin>>n;
    	if(n/111 >= n%11)
    	{
    		cout<<"YES\n";
		}
		else
		{
			cout<<"NO\n";
		}
	}
	
	
	return 0;
}