#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
using vll = vector<ll>;
void done() {
int n;
cin >> n;
vll a(n), b(n);
for (ll &x : a) cin >> x;
for (ll &x : b) cin >> x;
if (n < 3) {
cout << "Yes\n";
return;
}
sort(a.begin(), a.end());
sort(b.begin(), b.end());
bool f = true;
for (int i = 1; i < n - 1; ++i) {
bool is_peak = (a[i] > b[i+1]) || (b[i] > a[i+1]);
if (!is_peak) {
f = false;
break;
}
}
cout << (f ? "Yes\n" : "No\n");
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
done();
}
return 0;
}