#include <bits/stdc++.h>
using namespace std;
#define int long long
void iusearchbtw () {
int n; cin >> n;
vector<int> a(n + 1), b(n + 1);
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) cin >> b[i];
sort(a.begin() + 1, a.end());
sort(b.begin() + 1, b.end());
bool ok = 1;
for (int i = 2; i <= n - 1; i++) {
ok &= ((a[i - 1] < b[i] && b[i] > a[i + 1]) || (b[i - 1] < a[i] && a[i] > b[i + 1]));
}
cout << (ok ? "Yes\n" : "No\n");
}
signed main () {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int tt = 1;
cin >> tt;
while (tt --> 0) iusearchbtw();
}