using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray(); public static void Main() { Solve(); } static void Solve() { var t = NN; var ans = new bool[t]; for (var u = 0; u < t; ++u) { var n = NN; var a = NList; ans[u] = Judge(n, a); } WriteLine(string.Join("\n", ans.Select(f => f ? "Yes" : "No"))); } static bool Judge(int n, int[] a) { var flength = 0; for (var i = 0; i + 1 < a.Length; ++i) { if (a[i] == 1 && a[i + 1] == n) { flength = i + 1; break; } } if (flength == 0) { for (var i = 0; i < n; ++i) { if (a[i] != i + 1 || a[i + n] != i + 1) return false; } } else { var nl = new List(); var div = flength / 2 + 1; for (var i = 1; i <= div; ++i) nl.Add(i); for (var i = div - 1; i > 0; --i) nl.Add(i); for (var i = n; i >= div; --i) nl.Add(i); for (var i = div + 1; i <= n; ++i) nl.Add(i); for (var i = 0; i < a.Length; ++i) if (a[i] != nl[i]) return false; } return true; } }