//Don't Panic
//Read the q properly
//Don't see the standings until the contest is over.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define vsum(v) accumulate(v.begin(),v.end(),0LL)
#define maxi(v) *max_element(v.begin(),v.end())
#define mini(v) *min_element(v.begin(),v.end())
#define sort(v) sort(v.begin(),v.end())
const int N=1e7+10;
// vector<bool> isPrime(N,1);
// vector<int> hp(N,0),lp(N,0);
//a+b=(a ^b)+2.(a&b)
//function to check whether a given number is prime or not
bool checkPrime(int n) {
if (n<=1) return false;
if (n<=3) return true;
if (n%2==0 || n%3==0) return false;
for(int i=5; i*i<=n;i+=6) {
if(n%i==0 || n%(i+2)==0)
return false;
}
return true;
}
//sieve
// void sieve(){
// isPrime[0]=isPrime[1]=false;
// for(int i=2;i<N;i++){
// if(isPrime[i]==true){
// lp[i]=hp[i]=i;
// for(int j=2*i;j<N;j+=i){
// isPrime[j]=false;
// hp[j]=i;
// if(lp[j]==0){
// lp[j]=i;
// }
// }
// }
// }
// }
void solve(){
//code yaha par likh
int n;
cin>>n;
vector<int> a(n);
vector<int> b(n);
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<n;i++){
cin>>b[i];
}
if(n<3){
cout<<"Yes"<<endl;
return;
}
sort(a);
sort(b);
for(int i=2;i<n;i++){
swap(a[i],a[i-1]);
// swap(b[i],b[i-1]);
}
int cnt=0;
for(int i=1;i<n-1;i++){
if((a[i]>b[i-1] && a[i]>b[i+1]) || (b[i]>a[i-1] && b[i]>a[i+1])) cnt++;
else break;
}
if(cnt==n-2) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// int t=1;
int t;cin>>t;
while(t--){
solve();
}
}