//#pragma GCC target("avx2") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") #include using namespace std; using ll = long long; using pii = pair; using pll = pair; using pli = pair; #define MOD 998244353 //#define MOD 1000000007 #define el '\n' #define El '\n' #define YESNO(x) ((x) ? "Alice" : "Bob") #define YES YESNO(true) #define NO YESNO(false) #define EXIT_ANS(x) {cout << (x) << '\n'; return;} template void inline SORT(T &v){sort(v.begin(),v.end()); return;} template void inline REV(T &v){reverse(v.begin(),v.end()); return;} template void inline VEC_UNIQ(T &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end()); return;} template auto inline MAX(T &v){return *max_element(v.begin(),v.end());} template auto inline MIN(T &v){return *min_element(v.begin(),v.end());} template auto inline SUM(vector &v){T ans = 0; for(int i = 0; i < (int)v.size(); i++)ans += v[i]; return ans;} template void inline DEC(T &v){for(int i = 0; i < (int)v.size(); i++)v[i]--; return;} template void inline INC(T &v){for(int i = 0; i < (int)v.size(); i++)v[i]++; return;} void inline TEST(void){cerr << "TEST" << endl; return;} template bool inline chmin(T &x,S y){ if(x > (T)y){ x = (T)y; return true; } return false; } template bool inline chmax(T &x,S y){ if(x < (T)y){ x = (T)y; return true; } return false; } template vector inline get_vec(int n){ vector ans(n); for(int i = 0; i < n; i++)cin >> ans[i]; return ans; } template void inline print_vec(vector &vec,bool kaigyou = false){ int n = (int)vec.size(); for(int i = 0; i < n; i++){ cout << vec[i]; if(kaigyou || i == n - 1)cout << '\n'; else cout << ' '; } if(!n)cout << '\n'; return; } template void inline debug_vec(vector &vec,bool kaigyou = false){ int n = (int)vec.size(); for(int i = 0; i < n; i++){ cerr << vec[i]; if(kaigyou || i == n - 1)cerr << '\n'; else cerr << ' '; } if(!n)cerr << '\n'; return; } vector> inline get_graph(int n,int m = -1,bool direct = false,bool decrement = true){ if(m == -1)m = n - 1; vector> g(n); while(m--){ int u,v; cin >> u >> v; if(decrement)u--,v--; g[u].push_back(v); if(!direct)g[v].push_back(u); } return g; } template vector>> inline get_weighted_graph(int n,int m = -1,bool direct = false,bool decrement = true){ if(m == -1)m = n - 1; vector>> g(n); while(m--){ int u,v; cin >> u >> v; if(decrement)u--,v--; ll w; cin >> w; g[u].push_back(pair(w,v)); if(!direct)g[v].push_back(pair(w,u)); } return g; } #define MULTI_TEST_CASE true void solve(void){ //問題を見たらまず「この問題設定から言えること」をいっぱい言う //よりシンプルな問題に言い換えられたら、言い換えた先の問題を自然言語ではっきりと書く //複数の解法のアイデアを思いついた時は全部メモしておく //g++ -D_GLIBCXX_DEBUG -Wall -O2 c.cpp -o o int n; cin >> n; vector a = get_vec(n); //Bob が勝てることの必要条件に「最初が 1 でない」「総和が偶数」があるっぽいが、これだけだと足りなさそう //1 の位置(ダジャレではない)が関係してそう?(問題設定的にもそこを見るのが自然な気がする) if(SUM(a) % 2)EXIT_ANS(YES); if(a[0] == 0)EXIT_ANS(YES); //1 から左(その1は含まない)の総和が奇数になっている必要がある? ll sm = 0; for(int i = 0; i < n; i++){ if(a[i] == 1)if(sm % 2 == 0)EXIT_ANS(YES); sm += a[i]; } cout << NO << El; return; } map,bool> mp; //この状態で先手に渡された時、先手必勝かどうか bool saiki(vector a){ if(mp.find(a) != mp.end())return mp[a]; if(a.empty())return false; int n = (int)a.size(); for(int i = 0; i < n; i++){ vector b = a; b[i]--; //if(a.size() == 1 && a[0] == 2)debug_vec(b); if(b[i] == 0){ while(b.back() != 0)b.pop_back(); b.pop_back(); } //if(a.size() == 1 && a[0] == 2)debug_vec(b); if(!saiki(b))return true; } return mp[a] = false; } void calc(void){ #define N 6 for(int n = 1; n <= N; n++){ int m = N; vector v(n,1); while(1){ if(!saiki(v))print_vec(v); // print_vec(v); // cout << YESNO(saiki(v)) << el; // cout << el; v[n - 1]++; for(int i = n - 1; i >= 1; i--){ if(v[i] <= m)continue; v[i] = 1; v[i - 1]++; } if(v[0] > m)break; } } return; } signed main(void){ cin.tie(nullptr); ios::sync_with_stdio(false); //calc(); return 0; int t = 1; if(MULTI_TEST_CASE)cin >> t; while(t--){ solve(); } return 0; }