#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  for (int t = 0; t < q; t++) {
    int n, k1, k2;
    cin >> n >> k1 >> k2;
    int fist[k1];
    int second[k2];
    int max1 = 0, max2 = 0;
    for (int i = 0; i < k1; i++) {
      cin >> fist[i];
      max1 = max(max1, fist[i]);
    }
    for (int i = 0; i < k2; i++) {
      cin >> second[i];
      max2 = max(max2, second[i]);
    }
    if (max1 > max2) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
