#include<bits/stdc++.h>
using namespace std;
string arr;
int t;
vector<int>p;
int main()
{
	cin >> t;
	while (t--)
	{
		cin >> arr;
		bool sy1 = 1, sy2 = 1;
		for (int i = 1; i < arr.length(); i++) {
			if (sy2==0&&arr[i] == '0' && arr[i - 1] == '0') {
				sy1 = 0;
			}
			if (arr[i] == '1' && arr[i - 1] == '1')
				sy2 = 0;
				
		}
		if (sy1==0&&sy2==0)cout << "NO" << endl;
		else cout << "YES" << endl;
	}

}