#include using namespace std; namespace std { template istream& operator>>(istream& is, pair& p) { return is >> p.first >> p.second; } template istream& operator>>(istream& is, tuple& t) { return apply([&is](auto&... xs) -> istream& { return (is >> ... >> xs); }, t); } template istream& operator>>(istream& is, tuple&& t) { return is >> t; } template >* = nullptr> auto operator>>(istream& is, R&& r) -> decltype(is >> *begin(r)) { for (auto&& e : r) { is >> e; } return is; } template ostream& operator<<(ostream& os, const pair& p) { return os << p.first << ' ' << p.second; } template ostream& operator<<(ostream& os, const tuple& t) { auto f = [&os](const auto&... xs) -> ostream& { [[maybe_unused]] auto sep = ""; ((os << exchange(sep, " ") << xs), ...); return os; }; return apply(f, t); } template >* = nullptr> auto operator<<(ostream& os, R&& r) -> decltype(os << *begin(r)) { auto sep = ""; for (auto&& e : r) { os << exchange(sep, " ") << e; } return os; } } // namespace std // end library #define show(...) static_cast(0) namespace std::ranges::views { namespace { void solve() { int n; cin >> n; vector a(n); cin >> a; int f = 1 << a[0]; for (int e : a | drop(1)) { int nf = 0; if (e) { if (f & 1) { nf |= 8; } if (f & 2) { nf |= 2; } if (f & 4) { nf |= 2; } if (f & 8) { nf |= 2; nf |= 8; } } else { if (f & 1) { nf |= 1; } if (f & 2) { nf |= 4; } if (f & 4) { nf |= 1; nf |= 4; } if (f & 8) { nf |= 1; } } f = nf; show(f); } cout << (f & 12 ? "Yes\n" : "No\n"); } } // namespace } // namespace std::ranges::views using views::solve; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while (t--) { solve(); } }