#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 200006
//#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
typedef long long ll;
int n , m;
char S[MAXN];

void solve() {
	scanf("%s",S + 1);
	n = strlen( S + 1 );
	int L = n + 1 , R = -1;
	rep( i , 1 , n ) {
		if( S[i] == '1' && S[i - 1] == '1' ) {
			R = i - 1; 
			break;
		}
	}
	per( i , n , 1 )
		if( S[i] == '0' && S[i + 1] == '0' ) {
			L = i + 1;
			break;
		}
	if( L == n + 1 || R == -1 || L <= R ) puts("YES");
	else puts("NO");
}

signed main() {
    int T;cin >> T;while( T-- ) solve();
//    solve();
}
