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

void solve() {
	string s;
	cin >> s;
	for (int i = 1; i < s.size(); ++i) {
		if (s[i] == '1' && s[i - 1] == '1') {
			for (int j = i + 1; j < s.size(); ++j) {
				if (s[j] == '0' && s[j - 1] == '0') {
					cout << "NO\n";
					return;
				}
			}
			break;
		}
	}
	cout << "YES\n";
	return;
}
int main() {
	int T;
	cin >> T;
	while (T--) solve();
	return 0;
}