#include <bits/stdc++.h>
using namespace std;
#define MOD 998244353
#define ll long long
#define ull unsigned long long
#define ld long double
const int MAX_n = 1e5 + 5;
#define MAX_X 1000000
const int InF = 1e9; // for int
const ll INF = 1e18; // for ll
bool fuska(const vector<int> &a, const vector<int> &b, int n)
{
for (int i = 1; i < n - 1; i++)
{
if (!(a[i] > b[i - 1] && a[i] > b[i + 1]))
{
return false;
}
}
for (int i = 1; i < n - 1; i++)
{
if (!(b[i] > a[i - 1] && b[i] > a[i + 1]))
{
return false;
}
}
return true;
}
void solve()
{
int t;
cin >> t;
while (t--)
{
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];
}
sort(a.begin(), a.end());
sort(b.begin(), b.end(), greater<>());
bool ans = 0;
if (fuska(a, b, n))
{
ans = 1;
}
sort(a.begin(), a.end(), greater<>());
sort(b.begin(), b.end());
if (fuska(a, b, n))
{
ans = 1;
}
if (ans)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}