#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k1, k2;
    cin >> n >> k1 >> k2;
    vector<int> arr1(k1), arr2(k2);
    for (int i = 0; i < k1; i++) cin >> arr1[i];
    for (int i = 0; i < k2; i++) cin >> arr2[i];
    sort(arr1.begin(), arr1.end());
    sort(arr2.begin(), arr2.end());
    if (arr1[k1 - 1] > arr2[k2 - 1])
      cout << "YES" << '\n';
    else
      cout << "NO" << '\n';
  }
  return 0;
}
