//#include <bits/stdc++.h>                      Not a standard header file of GNU C++ library.

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include<vector>
#include<set>
#include<iomanip>                       // setprecision()
//---------------------------------------------------
#define l_int                       long long int
#define double                      long double
#define inf                         INT64_MAX
#define mod                         1000000005
#define fo(i,a,b)                   for(l_int i=a;i<b;i++)
//---------------------------------------------------
using namespace std;


int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);  cout.tie(NULL);
	l_int t;
	string s;
	cin>>t;
	while(t--)
	{
		cin>>s;
		int l=s.length();
		bool one=false,ans=true;
		for(int i=0;i<l;i++)
		{
			if(one)
			{
				if(i<l-1 && s[i]=='0' && s[i+1]=='0')
				{
					ans=false;
					break; 
				}
			}
			else
			{
				if(i<l-1 && s[i]=='1' && s[i+1]=='1')
				{
					one=true; 
					i++;
				}
				
			}
		}
	if(ans) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
		
		
	}
	

	return 0;
}
