#include <bits/stdc++.h>
using namespace std;
void solve() {
  int k1, k2, n;
  cin >> n >> k1 >> k2;
  std::vector<int> v1(k1), v2(k2);
  for (int i = 0; i < k1; i++) cin >> v1[i];
  for (int i = 0; i < k2; i++) cin >> v2[i];
  while (!v1.empty() && !v2.empty()) {
    sort(begin(v1), end(v1));
    sort(begin(v2), end(v2));
    if (v1.back() > v2.back()) {
      v1.push_back(v2.back());
      v2.pop_back();
    } else {
      v2.push_back(v1.back());
      v1.pop_back();
    }
  }
  if (v1.empty())
    cout << "No\n";
  else
    cout << "Yes\n";
}
int main() {
  ios::sync_with_stdio(false);
  int q = 1;
  cin >> q;
  for (long long i = 1; i <= q; i++) {
    solve();
  }
}
