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