package Implementation;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
* @author -- rajatgoyal715
*/
public class LarrysArray {
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int t=Integer.parseInt(br.readLine());
while(t--!=0){
int n=Integer.parseInt(br.readLine());
String s[]=br.readLine().split(" ");
int a[]=new int[n];
for(int i=0;i 1 3 2
temp=a[i+1];
a[i+1]=a[i];
a[i]=a[i-1];
a[i-1]=temp;
}
else if(a[i+1] 1 2 3
temp=a[i-1];
a[i-1]=a[i];
a[i]=a[i+1];
a[i+1]=temp;
}
else{
//2 1 3 -> 1 3 2
temp=a[i-1];
a[i-1]=a[i];
a[i]=a[i+1];
a[i+1]=temp;
}
}
else{
if(a[i-2]>a[i]){
//2 3 1 -> 1 2 3
temp=a[i];
a[i]=a[i-1];
a[i-1]=a[i-2];
a[i-2]=temp;
}
}
}
else{
count+=1;
}
prev=a[i];
}
if(count==n-1){
flag1=true;
break;
}
}
System.out.println((flag1)?"YES":"NO");
}
}
}