import math n = int(input()) ks = [0] * n temp = [] for i in range(n): k = int(input()) ks[i] = k temp.append(list(map(int, input().strip().split(" ")))) # print(ks, temp) def four_season(k: int, temp: list[int]) -> bool: # print(k, temp) max_i = -1 max_v = -math.inf min_i = -1 min_v = math.inf if len(temp) == 4: for i in range(len(temp)): v = temp[i] if v > max_v: max_i = i max_v = v if v < min_v: min_i = i min_v = v # print(max_i, max_v, min_i, min_v) if temp[min_i - 2 % 4] == max_v: return True if temp[max_i - 2 % 4] == min_v: return True return False for i in range(k): new_temp = [0] * 4 for j in range(len(temp)): idx = (i + j) % len(temp) # print(temp, idx) new_temp[j // k] += temp[idx] # print(new_temp) if four_season(1, new_temp): return True return False for i in range(n): if len(temp[i]) / ks[i] != 4: print("No") continue if four_season(ks[i], temp[i]): print("Yes") else: print("No")