#include<iostream>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<cstring>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<climits>
#include<cmath>

using namespace std;
#define int long long
#define pp pair<int,int>
#define ppl pair<ll,ll> 
#define mod 1000000007

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int t;
	cin>>t;

	while(t--)
	{
		int num;
		cin >> num;

		if ((num % 111) == 0)
			cout << "YES\n";

		else
		{
			while (num > 0)
			{
				if ((num % 11) == 0)
					break;

				num -= 111;
			}

			if (num >= 0)
				cout << "YES\n";

			else
				cout << "NO\n";
		}
	}

	return 0;
}