/*AUTHOR:
  YENNA
     SAI RAM REDDY
     */
/*===============Today is another chance to get better================*/
#include<bits/stdc++.h>
using namespace std ;
typedef vector<long long>  vi ;
typedef pair<long long,long long>  pii ;
#define  uli  unsigned long long
#define   lli   long long
#define db      double
#define ldb   long double
typedef   vector<pii>  vii ;
typedef   vector<vi>  vil ;
typedef map<lli, lli> mapll;
typedef map<string, lli> mapsl;
typedef vector<string> vs;
#define  mod    1000000007
#define  Pi     acos(-1)
#define inf      1e16
#define  rep(i,n)    for(i=0;i<n;i++)
#define  REP(i,k,n)   for(i=k;i<=n;i++)
#define  REPR(i,k,n)   for(i=k;i>=n;i--)
#define sl(x) scanf("%lld",&x)
#define pl(x) printf("%lld",x)
#define ou(a) ll a; cout<<a;
#define llin(a) ll a; cin>>a;
#define  pb     push_back
#define  pf      push_front
#define  mp    make_pair
#define   ALL(v)      v.begin(),v.end()
#define  SORT(v)     sort(ALL(v))
#define  REVERSE(v)        reverse(ALL(v))
#define    ALLA(arr, sz)      arr, arr + sz
#define    SZ     size
#define  elif          else if
#define TC(t)    while(t--)
#define  fi     first
#define  si     second
#define eb    emplace_back
#define   nxtp   next_permutation
#define    ub   upper_bound
#define   lb   lower_bound
#define  bpc(x)  __builtin_popcountll(x)
#define   bs     binary_search
#define   mset(c,x) memset (c, x, sizeof (c))
#define DEBUG(x) { cerr << #x << " = " << x << endl; }
#define IOS   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PR(a,n) {cerr<<#a<<" = "; FOR(_,1,n) cerr << a[_] << ' '; cerr <<endl;}
#define PR0(a,n) {cerr<<#a<<" = ";REP(_,n) cerr << a[_] << ' '; cerr << endl;}
#define cs(a)  {cout<<"Case"<<" "<<a<<":"<<" ";}

lli dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};

lli power(lli a,lli b)
{
 lli res=1;

 while(b)
    {
    if(b%2)
    res=(res*a)%mod;
    b=b>>1;
    a=(a*a)%mod;
    }
      return res;
}


int main()
{

       IOS

        /*#ifndef ONLINE_JUDGE
      freopen("in10.txt", "r", stdin);
      freopen("out10.txt","w",stdout);*/

         lli t;cin>>t;

           TC(t)
           {
              string s;cin>>s;

                lli i,flag=0,flag1=0;
                REPR(i,s.length()-1,1)
                {
                  if(s[i]=='0' && s[i-1]=='0')
                  {
                     flag=1;
                  }
                  elif(s[i]=='1' && s[i-1]=='1')
                  {
                    if(flag==1)
                   flag1=1;
                  }
                }

                 if(flag1)
                 {
                   cout<<"NO\n";
                 }
                 else
                 {
                    cout<<"YES\n";
                 }




           }



        return 0;
}
