#include<bits/stdc++.h>

using namespace std;
int main()
{
    int t;
    cin>>t;
    vector<string> res;
    while(t--)
    {
        string s;
        cin>>s;
        size_t pos11=s.find("11");
        if(pos11!=string::npos && s.find("00",pos11)!=string::npos)
        {
            res.push_back("NO");
        }
        else
        {
            res.push_back("YES");
        }
    }
    for(auto i:res)
    {
        cout<<i<<endl;
    }
}