#include <bits/stdc++.h>
#define nl '\n'
#define ll long long int
#define all(c) c.begin(),c.end()
#define print(c) for(auto e : c) cout << e << " "; cout << nl
using namespace std;
void solve()
{
int n; cin >> n;
vector<int> a(n), b(n);
for(auto &e: a) cin >> e;
for(auto &e: b) cin >> e;
sort(all(a)); reverse(all(a));
sort(all(b));
bool ok = true;
for(int i=1; i<n-1; i++)
{
if(a[i] <= b[i-1] || a[i] <= b[i+1])
{
ok = false;
}
}
if(ok)
{
cout << "Yes" << nl; return;
}
reverse(all(a));
reverse(all(b));
ok = true;
for(int i=1; i<n-1; i++)
{
if(b[i] <= a[i-1] || b[i] <= a[i+1])
{
ok = false;
}
}
if(ok) cout << "Yes" << nl;
else cout << "No" << nl;
}
int main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL);
int t = 1;
cin >> t; // multiple tc
for(int tt = 1; tt <= t; tt++)
{
// cout << "TEST CASE-" << tt << nl;
solve();
}
return 0;
}