#include <bits/stdc++.h>
using namespace std;
inline int read(void)
{
    int sum = 0, sign = 1;
    char ch = getchar();
    while (ch > '9' || ch < '0')
    {
        if (ch == '-')
            sign = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
    {
        sum = sum * 10 + ch - '0';
        ch = getchar();
    }
    return sum * sign;
}
const int maxn = 2e5 + 5;
typedef long long ll;
int main()
{
    int T = read();
    for (int cas = 1; cas <= T; cas++)
    {
        string str;
        cin >> str;
        int bol = 0;
        for (int i = str.length() - 1; i >= 1; i--){
            if (bol == 0 && str[i] == '0' && str[i - 1] == '0')
                bol = 1;
            if (bol == 1 && str[i] == '1' && str[i - 1] == '1')
                bol = 2;
        }
        if (bol == 2)
            cout << "NO\n";
        else
            cout << "YES\n";
    }
    return 0;
}