import sys sys.setrecursionlimit(10 ** 6) def input(): return sys.stdin.readline().rstrip() def main(): # 1回調べれば良い t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) for i in range(n): if a[i] != i + 1: for j in range(n): a[i + j], a[i + n - j] = a[i + n - j], a[i + j] if a == list(range(1, n + 1)): print("Yes") else: print("No") break else: print("Yes") if __name__ == '__main__': main()