/* An ACEASH Source code  */
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double

#define vi vector<int>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>

#define vvi vector< vector < int > >
#define vvl vector< vector < ll > >

#define pii pair< int , int >
#define pll pair< ll , ll >

#define vpl vector< pll >
#define vpi vector< pii >

#define MOD 1000000007

#define mp make_pair
#define pb push_back

#define sare(v) (v).begin(),(v).end()
#define ulta(v) (v).rbegin(),(v).rend()

#define F first
#define S second

#define tez  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const ld pie = 3.1415926535897932384626 ;
const ll N=1e5 +9;

int main()
{
    ll t;
    cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        s+='1';
        ll l=s.length();
        ll a=0,b=0;
        for(ll i=0;i<l-1;i++)
        {
            if(s[i]=='1' && s[i+1]=='1'){a=1;}
            else if((s[i]=='0' && s[i+1]=='0') && a==1){b=1; break;}
        }
        if(b==0){cout<<"YES\n";}
        else{cout<<"NO\n";}
    }

    

    



    return 0;
}



