import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        for( int t = 0; t < T; t++ ) {
            int N = sc.nextInt();
            int[] A = new int[2*N];
            int[] X = new int[2*N];
            boolean possible = false;
            boolean first = true;
            for( int i = 0; i < 2*N; i++ ) {
                A[i] = sc.nextInt()-1;
                X[i] = i%N;
                if( A[i] != i%N ) first = false;
            }
            for( int i = 0; i < N; i++ ) {
                rev(N,i,X);
                boolean frag = true;
                for( int j = 0; j < 2*N; j++ ) {
                    if( A[j] != X[j] ) frag = false;
                }
                if( frag ) possible = true;
                rev(N,i,X);
            }
            System.out.println( possible||first ? "Yes" : "No" );
        }
        
    }
    
    static void rev( int N, int k, int[] A ) {
        
        for( int i = 0; i <= N/2; i++ ) {
            int save = A[i+k];
            A[i+k] = A[N+k-i];
            A[N+k-i] = save;
        }
        
    }
    
}