#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll>PII; const int N = 2e6 + 10; const int MOD = 998244353; const int INF = 0X3F3F3F3F; const int dx[] = {-1, 1, 0, 0, -1, -1, +1, +1}; const int dy[] = {0, 0, -1, 1, -1, +1, -1, +1}; const int M = 1e6 + 10; int q; int main() { cin >> q; while(q --){ string s; cin >> s; for(int i = 0; i < s.size() - 1; i ++) { if(s[i] != '0') s[i] ^= 1, s[i + 1] ^= 1; } string s1 = s; for(int i = 0; i < s.size() - 1; i ++) { if(s1[i] != '1') s1[i] ^= 1, s1[i + 1] ^= 1; } if(s[s.size() - 1] == '0' || s1[s.size() - 1] == '1') puts("Yes"); else puts("No"); } return 0; }