/* -*- coding: utf-8 -*- * * 3644.cc: No.3644 Division by Shitoshitoto Sequence - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 100000; const int MAX_N5 = MAX_N * 5; /* typedef */ /* global variables */ int as[MAX_N5]; /* subroutines */ bool stt(int xs[]) { return xs[0] == xs[2] && xs[1] == xs[3] && xs[1] == xs[4] && xs[0] != xs[1]; } /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { int n; scanf("%d", &n); int n5 = n * 5; for (int i = 0; i < n5; i++) scanf("%d", as + i); bool ok = true; for (int i = 0; ok && i < n5; i += 5) ok = stt(as + i); if (ok) puts("Yes"); else puts("No"); } return 0; }