#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ii> pii;
const int MAX= 2e5+5;
int T, N, M, K, a[MAX];
char s[MAX], r[MAX];

int main(int argc, char** argv) {
	scanf("%d", &T);
	while(T--) {
		bool ok = true;
		scanf("%s", s);
		int sz = strlen(s);
		bool um = true;
		rep(i, 0, sz) {
			if(um) {
				if(s[i] == '1' && i + 1 < sz && s[i+1] == '1')
						um = 0;
			} else {
				if(s[i] == '0' && i + 1 < sz && s[i+1] == '0')
					ok = false;
			}
		}
		
		printf("	%s\n", ok ? "YES" : "NO");
	}
	return 0;
}


