#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, n, p, q, a;
  cin >> t;
  while (t--) {
    cin >> n >> p >> q;
    vector<long long int> player1, player2;
    for (unsigned long long i = 0; i < p; i++) {
      cin >> a;
      player1.push_back(a);
    }
    for (unsigned long long i = 0; i < q; i++) {
      cin >> a;
      player2.push_back(a);
    }
    sort(player1.begin(), player1.end(), greater<long long int>());
    sort(player2.begin(), player2.end(), greater<long long int>());
    if (player1[0] > player2[0])
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
