#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
#define ll long long
#define fr(i, a, b) for (int i = a; i < b; i++)
#define all(a) a.begin(), a.end()
#define vi vector<int>
#define vs vector<string>
#define mpi map<int, int>
#define mpc map<char, int>
#define sti set<int>
#define maxn 207
int main()
{

    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int t;
    cin >> t;
    while (t--)
    {

     string s;
     cin>>s;

  int idx=-1;

  fr(i,1,s.length())
  {
      if(s[i]=='1'&&s[i-1]=='1')
     {
          idx=i;
          break;
     }

  }
  bool flag=true;
  if(idx!=-1)
 {
      fr(i,idx+1,s.length())
  {
      if(s[i]=='0'&&s[i-1]=='0')
       {
           flag=false;
           break;
       }
  }
      if(flag)
   cout<<"YES"<<endl;
   else
   {
       cout<<"NO"<<endl;
   }
 }
 else
 {
     cout<<"YES"<<endl;
 }
 
      




       
    }
}
