#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#include <utility>
#define ll long long
#define endl "\n"
using namespace std;
//struct cmp { bool operator()(const ll &a, const ll &b) const { return a < b; }};
//#define ordered_set tree<ll, null_type,cmp,rb_tree_tag, tree_order_statistics_node_update>
// st.find_by_order(index) gives the k-th smallest element (0-based index)
// st.order_of_key(x) gives the number of elements strictly less than x
#define sp(x) fixed << setprecision(x)
//int fx[]={+0,+0,+1,-1,-1,+1,-1,+1}; // Kings Move
//int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
// auto it = mp.find(x);if (it != mp.end())
//priority_queue<pair<ll, ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> pq;
//sort(vec.begin(), vec.end(),greater<int>());
//vector<bool> isPrime(limit + 1, true);
#define memo(a,b) memset(a,b,sizeof(a))
int main ()
{
ios_base::sync_with_stdio(0);cin.tie(0);
int test;
cin >>test;
while (test--)
{
ll n; cin>>n;
ll arr[n],brr[n];
for(ll i=0;i<n;i++) cin>>arr[i];
for(ll i=0;i<n;i++) cin>>brr[i];
sort(arr,arr+n);
sort(brr,brr+n);
bool ok=1;
for(ll i=1;i<n-1;i++)
{
bool a=arr[i]>brr[i+1] && arr[i]>brr[i-1];
bool b=brr[i]>arr[i+1] && brr[i]>arr[i-1];
if( !a && !b ) ok=0;
}
if(ok) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}