#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, k1, k2;
  cin >> t;
  while (t--) {
    cin >> n >> k1 >> k2;
    int arr1[k1], arr2[k2];
    for (int &in : arr1) cin >> in;
    for (int &in : arr2) cin >> in;
    sort(arr1, arr1 + k1);
    sort(arr2, arr2 + k2);
    cout << (arr1[k1 - 1] > arr2[k2 - 1] ? "YES" : "NO") << '\n';
  }
}
