#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define pb(x) emplace_back(x);
#define all(v) v.begin(), v.end()
#define allrev(v) v.rbegin(), v.rend()
ll M = 1000000007;
ll powM(ll b, ll p) {
    ll r=1;
    for(; p; b=b*b%M, p/=2)
    if(p&1)
        r=r*b%M;
    return r;
}
ll ncr(ll n, ll r){
    ll ans=1;
    for(ll i=n-r+1;i<=n;i++)ans*=i;
    for(ll i=1;i<=r;i++)ans = ans/i;
    return ans;
}
ll fact(ll n){
    if(n==0)return 1;
    ll ans=1;
    for(ll i=1;i<=n;i++)ans*=i;
    return ans;
}

void solve(){
    
    string s;
    cin>>s;

    bool b=true;

    for(int i=1;i<s.size();i++){
        if( s[i-1]=='1' && s[i]=='1' )b=false;
        if( s[i-1]=='0' && s[i]=='0' && !b ){
            cout<<"NO";
            return ;
        }
    }

    cout<<"YES";

    
}

int main(int argc, char *argv[]){
    fastIO;
    ll tc=1;
    cin>>tc;
    while(tc--){solve(); cout<<endl;}
    return 0;
}