// #define DEBUG
// #define F_INP
#define TCASE
// #define PB_DS
#include <bits/stdc++.h>
using namespace std;
string t_case() { static int tc; return "Case " + to_string(++tc) + ':'; }
#ifdef DEBUG
#define L_DELIM cerr << "{ "
#define R_DELIM cerr << " }"
#else
#define L_DELIM
#define R_DELIM
#endif
template <class T, size_t N> ostream& operator<<(ostream& out, const array<T, N>& A) { L_DELIM; for (int i = 0; i < N; i++) out << &" "[!i] << A[i]; R_DELIM; return out; }
template <class T, size_t N> istream& operator>>(istream& in, array<T, N>& A) { for (auto& a : A) in >> a; return in; }
#define TEM template <class... T>
TEM istream& operator>>(istream& in, pair<T...>& p) { return in >> p.first >> p.second; }
TEM ostream& operator<<(ostream& out, const pair<T...>& p) { L_DELIM; out << p.first << ", " << p.second; R_DELIM; return out; }
#define def_in(cont) TEM istream& operator>>(istream& in, cont<T...>& A) { for (auto& a : A) in >> a; return in; }
#define def_out(cont) TEM ostream& operator<<(ostream& out, const cont<T...>& A) { L_DELIM; int i = 0; auto it = A.begin(); while (it != A.end()) out << &" "[!i++] << *it++; R_DELIM; return out; }
def_in(vector) def_in(deque) def_out(vector) def_out(deque) def_out(set) def_out(map) def_out(multiset)
#ifdef PB_DS
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
TEM using ordered_set = tree<T..., null_type, less<T...>, rb_tree_tag, tree_order_statistics_node_update>;
TEM using ordered_multiset = tree<T..., null_type, less_equal<T...>, rb_tree_tag, tree_order_statistics_node_update>;
def_out(ordered_set) def_out(ordered_multiset)
#endif
TEM istream& c_in(T&... args) { return ((cin >> args), ...); }
TEM ostream& c_out(const T&... args) { int i = 0; return ((cout << &" "[!i++] << args), ...) << '\n'; }
ostream& c_out(bool b) { return c_out(b ? "Yes" : "No"); }
#ifdef DEBUG
TEM ostream& c_err(const T&... args) { int i = 0; return ((cerr << &" "[!i++] << args), ...) << '\n'; }
#else
#define c_err(...)
#endif
#define d_bug(args...) c_err(#args, '=', args)
#define endl '\n'
#define all(A) A.begin(), A.end()
#define rall(A) A.rbegin(), A.rend()
#define sum_of(A) accumulate(all(A), 0ll)
#define max_of(A) *max_element(all(A))
#define min_of(A) *min_element(all(A))
#define int long long
#define uint unsigned int
using VI = vector<int>;
using DI = deque<int>;
using SI = set<int>;
using MII = map<int, int>;
using VVI = vector<VI>;
template<size_t N> using AI = array<int, N>;
using II = AI<2>; // instead of pair<int, int>
using III = AI<3>; // ... tuple<int, int, int>
#define VMAT(n, m) VVI(n, VI(m))
#define AMAT(n, m) vector<AI<m>>(n)
#define FOR(i, l, r) for (int i = l; i <= r; i++)
#define ROF(i, l, r) for (int i = r; i >= l; i--)
void solve() {
c_err("");
c_err(t_case());
int n; c_in(n);
DI A(n), B(n); c_in(A, B);
sort(all(A));
sort(all(B));
bool final_ans = n <= 2;
if (!final_ans) FOR (_, 1, 2) {
DI C = A, D = B;
C.pop_front();
C.pop_front();
// swap(D[1], D[2]);
bool ans = true;
// D.pop_front();
// D.pop_front();
FOR (i, 0, n-3) ans &= C[i] > D[i] && C[i] > D[i+2];
final_ans |= ans;
swap(A, B);
}
c_out(final_ans);
}
signed main() {
#ifndef DEBUG
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#endif
#ifdef F_INP
freopen("input.txt", "r", stdin);
#endif
int t = 1;
#ifdef TCASE
cin >> t;
#endif
while (t--) solve();
return 0;
}