#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long

void solve()
{
    string str;
    cin>>str;
    int ptr = 1;
    while((ptr < str.length())&&((str[ptr]=='0')||(str[ptr-1]=='0')))
    {
        ++ptr;
    }
    if(ptr == str.length())
    {
        cout<<"YES\n";
        return;
    }
    ++ptr;
    while((ptr < str.length())&&((str[ptr]=='1')||(str[ptr-1]=='1')))
    {
        ++ptr;
    }
    if(ptr == str.length())
    {
        cout<<"YES\n";
        return;
    }
    cout<<"NO\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int i,t;
    cin>>t;
    for(i = 0;i < t;++i)
        solve();
}
