#include <bits/stdc++.h>
#include <cmath>
#include <bitset>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define lld long double
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pi acos(-1.00)
const ll mod = 1e9+7;
const ll inf = 1e18+10;
inline void evan()
{
ll n;cin>>n;
ll a[n+1];
ll b[n+1];
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=n;i++)cin>>b[i];
sort(a+1,a+n+1);
sort(b+1,b+n+1);
vector<ll>test1(n+1,0);
vector<ll>test2(n+1,0);
ll c=1;
for(int i=2;i<=n-1;i++){
if(test1[i-1]==0){test1[i-1]=a[c];c++;}
if(test1[i+1]==0){test1[i+1]=a[c];c++;}
}
c=1;
for(int i=2;i<=n-1;i++){
if(test2[i-1]==0){test2[i-1]=b[c];c++;}
if(test2[i+1]==0){test2[i+1]=b[c];c++;}
}
ll f=1;
for(int i=2;i<=n-1;i++){
if(test1[i-1]>=b[i]||test1[i+1]>=b[i])f=0;
}
if(f){yes;return;}
f=1;
for(int i=2;i<=n-1;i++){
if(test2[i-1]>=a[i]||test2[i+1]>=a[i])f=0;
}
if(f){yes;return;}
else no;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(nullptr);
ll t = 1;
cin >> t;
// cin.ignore();
for (ll i = 1; i <= t; i++)
{
evan();
}
}