#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(x) (x).begin(), (x).end()
#define f(i, n) for (int i = 0; i < n; i++)
#define trace(x) cerr << #x << ": " << x << '\n'
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vector<int> a(n), b(n);
multiset<int> s1, s2;
f(i, n)
{
cin >> a[i];
s1.insert(a[i]);
}
f(i, n)
{
cin >> b[i];
s2.insert(b[i]);
}
if (n < 3)
{
cout << "Yes\n";
continue;
}
// try a;
sort(all(a));
sort(all(b));
reverse(all(b));
vector<int> ta(n);
int j = 1, i = n - 1;
while (j < n - 1)
{
ta[j++] = a[i--];
}
int f = 1;
for (int i = 1; i < n - 1; i++)
{
if (ta[i] > b[i - 1] and ta[i] > b[i + 1])
{
}
else
f = 0;
}
if (f)
{
cout << "Yes\n";
continue;
}
// try b;
sort(all(b));
sort(all(a));
vector<int> tb(n);
reverse(all(a));
j = 1, i = n - 1;
while (j < n - 1)
{
tb[j++] = b[i--];
}
f = 1;
for (int i = 1; i < n - 1; i++)
{
if (tb[i] > a[i - 1] and tb[i] > a[i + 1])
{
}
else
f = 0;
}
if (f)
{
cout << "Yes\n";
continue;
}
cout << "No\n";
}
}