#include int n; int a[2003]; int cnt[1003]; void solve() { int i; for (i = 0; i <= n; i++) cnt[i] = 0; for (i = 0; i < 2 * n; i++) cnt[a[i]]++; for (i = 1; i <= n; i++) { if (cnt[i] != 2) { printf("No\n"); return; } } if (a[0] != 1 || a[2 * n - 1] != n) { printf("No\n"); return; } for (i = 0; i < 2 * n - 1; i++) { if (a[i] - a[i + 1] == 1) continue; if (a[i] - a[i + 1] == -1) continue; if (a[i] - a[i + 1] == n - 1) continue; if (a[i] - a[i + 1] == 1 - n) continue; printf("No\n"); return; } printf("Yes\n"); return; } int main() { int t; scanf("%d", &t); int i; for (; t > 0; t--) { scanf("%d", &n); for (i = 0; i < 2 * n; i++) scanf("%d", &a[i]); solve(); } return 0; }