#include #include using namespace std; const int MAXN = 100000 + 10; int tn, n, a[MAXN], sp; bool eq (int x, int y) { if (x == -1 || y == -1) return true; if (x == y) return true; return false; } void rec (int startPos) { a[startPos] = a[startPos + 1] = a[startPos + 2] = -1; for(int i = max(1, startPos - 2); i < startPos; i++) if ((a[i] + a[i + 1] + a[i + 2] != -3) && (eq(a[i], a[i + 1]) && eq(a[i], a[i + 2]) && eq(a[i + 1], a[i + 2]))) rec(i); for(int i = startPos + 1; i <= min(n - 2, startPos + 2); i++) if ((a[i] + a[i + 1] + a[i + 2]) != -3 && eq(a[i], a[i + 1]) && eq(a[i + 1], a[i + 2]) && eq(a[i], a[i + 2])) rec(i); } int main(int argc, const char * argv[]) { cin >> tn; while (tn--) { cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]; sp = 0; bool fNo = true; for(int i = 1; i <= n - 2; i++) if (eq(a[i], a[i + 1]) && eq(a[i], a[i + 2])) { fNo = false; } // for(int i = 1; i <= n; i++) if (a[i] != -1) // fNo = true; if (!fNo) cout << "Yes" << endl; else cout << "No" << endl; } return 0; }