#include using namespace std; int main(){ int T; cin >> T; while (T--){ int N; cin >> N; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } bool ok = true; for (int i = 0; i < N; i++){ if (A[i] == 0 and A[(i + 1) % N] == 0){ ok = false; } if (A[i] == 2 and A[(i + 1) % N] == 2){ ok = false; } } if (A == vector(N, 1)){ ok = false; } if (ok){ cout << "Yes" << endl; } else { cout << "No" << endl; } } }