#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int k1, k2;
  cin >> k1 >> k2;
  int max1 = 0, max2 = 0;
  for (int i = 0; i < k1; ++i) {
    int cur;
    cin >> cur;
    max1 = max(max1, cur);
  }
  for (int i = 0; i < k2; ++i) {
    int cur;
    cin >> cur;
    max2 = max(max2, cur);
  }
  if (max1 > max2) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
