#include<bits/stdc++.h>

using namespace std;

int main()
{	
	ios::sync_with_stdio(false);
 
	int t;
	cin >> t;
	while(t--)
	{
		string s;
		cin >> s;
		int len = s.length();
		int m = 1;
		int p[2] = {-1,-1};
		for(int i = 0;i < len-1;i++)
		{

			if(s[i] == s[i+1])
			{
				p[s[i]-'0'] = i;
				//cout <<s[i] << "="<<p[s[i]] << endl;
			}
			//cout << p[0] << " " << p[1] << endl;
			if(p[0]>=0&&p[1]>=0&&p[1]<p[0])
			{
				//cout << "66666" << endl;
				m = 0;
				break;
			}
		}
		//cout << m << endl;
		if(m) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	
	return 0;
}