#include using namespace std; void solve() { int n; cin >> n; vector a(n); for (int i = 0; i < n; i ++) cin >> a[i]; vector> b; for (int i = 0, j; i < n; i = j + 1) { j = i; while (j + 1 < n && a[j + 1] == a[i]) ++ j; b.push_back({ a[i], j > i }); } if (b.size() % 2 == 0) { cout << "Yes\n"; } else { bool flag = false; for (int i = 1; i < (int) b.size(); i += 2) if (b[i].second) flag = true; if (flag) cout << "Yes\n"; else cout << "No\n"; } } int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); int tt; cin >> tt; while (tt --) solve(); return 0; }