#include<iostream>

using namespace std;


int main()
{
    ios::sync_with_stdio(0);

    int t;
    cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        bool flag = 0;
        bool ch = 0;
        for(int i = 0;i<s.size();i++)
        {
            if(i >= 1 && s[i] == '1' && s[i-1] == '1')
            {
                flag =1 ;
            }
            else if(flag == 1 && i > 1 && s[i-1] == '0' && s[i] == '0' )
            {
                ch = 1;
                break;
            }
        }

        if(ch)
            cout<<"NO";
        else
            cout<<"YES";
        cout<<'\n';
    }
}
