#include #include using namespace std; int s[2009], a[2009]; int main() { ios::sync_with_stdio(false); cin.tie(0); int tc; cin >> tc; for (int ti = 0; ti < tc; ti++) { int n; cin >> n; bool rf = true; for (int i = 1; i <= 2 * n; i++) { cin >> a[i]; s[i] = i; if (i > n) s[i] -= n; if (a[i] != s[i]) rf = false; } for (int i = 1; i <= n; i++) { reverse(s + i, s + n + i + 1); bool f = true; for (int j = 1; j <= 2 * n; j++) if (s[j] != a[j]) { f = false; break; } if (f) { rf = true; break; } reverse(s + i, s + n + i + 1); } if (rf) cout << "Yes" << '\n'; else cout << "No" << '\n'; } return 0; }