#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vi vector<int>
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1e9 + 7;
void solve()
{
    string s;
    cin>>s;
    int n = s.size();
    int a = -1,b = n;
    for(int i=1;i<n;i++){
        if(s[i] == '0' && s[i-1] == '0'){
            a = i;
        }
        if(s[i] == '1' && s[i-1] == '1' && b == n){
            b = i-1;
        }
    }

    if(a < b){
        cout<<"YES\n";
    }else{
        cout<<"NO\n";
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tests = 1;
    cin>>tests;
    while (tests--)
    {
        solve();
    }
    return 0;
}