#include<iostream>
using namespace std;

void solve(int n) {
	for (int i = 0; i <= 10; i++) {
		if ((n - i * 111) >= 0 && ((n - i * 111) % 11) == 0) {
			cout << "YES\n";
			return;
		}
	}
	cout << "NO\n";
}

int main() {
	int tt;
	cin >> tt;
	while (tt--) {
		int n;
		cin >> n;
		solve(n);
	}
}