using System; public class Hello { static void Main() { var t = int.Parse(Console.ReadLine().Trim()); while (t-- > 0) { var n = int.Parse(Console.ReadLine().Trim()); string[] line = ("0 " + Console.ReadLine().Trim()).Split(' '); var a = Array.ConvertAll(line, int.Parse); getAns(n, a); } } static int[] change(int n, int t) { var a = new int[2 * n + 1]; var b = new int[2 * n + 1]; for (int i = 1; i <= n; i++) { a[i] = i; a[i + n] = i; b[i] = i; b[i + n] = i; } var p = t + n - 1; var imax = p; for (int i = t + 1; i <= imax; i++) a[i] = b[p--]; return a; } static bool check(int n, int[] a, int t) { var ok = true; for (int i = 1; i <= n; i++) if (a[i] != a[i + n]) { ok = false; break; } if (ok) return true; var b = change(n, t); for (int i = 1; i <= 2 * n; i++) { if (a[i] != b[i]) return false; } return true; } static void getAns(int n, int[] a) { var k = 0; for (int i = 1; i <= n; i++) if (a[i] == a[i + n]) k = i; Console.WriteLine(check(n, a, k) ? "Yes" : "No"); } }