#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long int ll;
#define pll pair<ll, ll>
#define mll map<ll, ll>
#define mii map<int , int>
#define vl vector<ll>
#define vll vector<pll>
#define mod 1000000007
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rerep(i, a, b) for (ll i = a; i >= b; i--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) v.begin(), v.end()
#define dall(v) v.begin(), v.end(), greater<ll>()
#define vecin(v) for (ll & x : v){cin >> x;}
#define outvec(v) rep(i, 0, v.size()) { cout << v[i] << " "; }
using namespace std::chrono;



int main() {
	fast_io;
	ll t;
	cin >> t;
	while(t--){
		string s;
		cin >> s;
		bool le = false;
		for(int i = 1; i < s.size(); i++){
			if(s[i] == '1' && s[i-1] == '1'){
				for(int j = i; j < s.size()-1; j++){
					if(s[j] == '0' && s[j+1] == '0'){
						le = true;
					}
				}
				break;
			}
		}
		if(le){
			cout << "NO \n";
		}
		else{
			cout << "YES \n";
		}
	}
    return 0;
}