Symmetrical Glade
Not all forests are magical, but for a forest to be considered magical, it must meet several criteria. While many of these criteria are still under study, one is certain: a forest cannot be magical without a round symmetrical clearing.
Let's simplify the scenario by considering a forest where only birches and pines grow. In this forest, there is exactly one round clearing, surrounded by n trees. Each tree is either a pine or a birch. The axis of the clearing is a line that runs through the center of the clearing, dividing it into two equal halves. If this line passes through a tree, the tree is considered to be in both halves. A clearing is symmetrical if one half is a mirror image of the other, making it an axis of symmetry. Here are examples of symmetrical clearings (white circles represent birches, black circles represent pines):
Conversely, the following clearing is not symmetrical, regardless of the axis chosen:
Input
The first line of the input contains a single integer T (1 ≤ T ≤ 10), representing the number of test cases. Each test case is described in two lines.
The first line of each test case contains an integer n (2 ≤ n ≤ 10^5), indicating the number of trees around the clearing. The second line contains n integers a_i (0 ≤ a_i ≤ 1), representing the trees in clockwise order, where 0 denotes a birch and 1 denotes a pine.
Output
For each test case, output a single line with the result. Write Yes if the clearing has an axis of symmetry, and No if it does not.