#include <bits/stdc++.h>
using namespace std;
int n, t, a, b, i, k1, k2, kozirA[101], kozirB[101];
int main() {
  cin >> t;
  while (t--) {
    cin >> n >> k1 >> k2;
    for (i = 0; i < k1; i++) {
      cin >> a;
      kozirA[i] = a;
    }
    sort(kozirA, kozirA + k1);
    for (i = 0; i < k2; i++) {
      cin >> b;
      kozirB[i] = b;
    }
    sort(kozirB, kozirB + k2);
    if (kozirA[k1 - 1] > kozirB[k2 - 1]) cout << "YES" << endl;
    if (kozirA[k1 - 1] < kozirB[k2 - 1]) cout << "NO" << endl;
  }
}
