#include<bits/stdc++.h>
#define N 1000000007
#define MAX 10000000000000
#define ll long long
#define e 100005

//string binary = std::bitset<8>(5).to_string();
using namespace  std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t;
    cin>>t;
    while(t--)
    {
    string ch;
    cin>>ch;
    int test=0;

    int pos1=ch.length();
    int pos2=0;
    for(int i=0;i<ch.length()-1;i++)
    {
        if((ch[i]=='1')and(ch[i+1]=='1'))
        {
            pos1=i;
            break;
        }
    }
    for(int i=0;i<ch.length()-1;i++)
    {
        if((ch[i]=='0')and(ch[i+1]=='0'))
        {
            pos2=i;
        }
    }
    if(pos1>=pos2)
    cout<<"YES";
    else
    cout<<"NO";
    cout<<endl;
    }
    return(0);
}
