#include <bits/stdc++.h>
long long arr[200005];
long long fck[100005];
void merge(long long arr[], int l, int m, int r) {
  int i, j, k;
  int n1 = m - l + 1;
  int n2 = r - m;
  int L[n1], R[n2];
  for (i = 0; i < n1; i++) L[i] = arr[l + i];
  for (j = 0; j < n2; j++) R[j] = arr[m + 1 + j];
  i = 0;
  j = 0;
  k = l;
  while (i < n1 && j < n2) {
    if (L[i] <= R[j]) {
      arr[k] = L[i];
      i++;
    } else {
      arr[k] = R[j];
      j++;
    }
    k++;
  }
  while (i < n1) {
    arr[k] = L[i];
    i++;
    k++;
  }
  while (j < n2) {
    arr[k] = R[j];
    j++;
    k++;
  }
}
void mergeSort(long long arr[], int l, int r) {
  if (l < r) {
    int m = l + (r - l) / 2;
    mergeSort(arr, l, m);
    mergeSort(arr, m + 1, r);
    merge(arr, l, m, r);
  }
}
int main() {
  long long count, n, q, i, j, k, x, y, z, l, ans, min, f, len, m, r, c, t, max,
      b, h;
  scanf("%lld", &t);
  for (i = 0; i < t; i++) {
    scanf("%lld %lld %lld", &n, &x, &y);
    for (j = 0; j < x; j++) scanf("%lld", &arr[j]);
    for (j = 0; j < y; j++) scanf("%lld", &fck[j]);
    mergeSort(arr, 0, x - 1);
    mergeSort(fck, 0, y - 1);
    m = x - 1;
    n = y - 1;
    while (arr[0] != 0 && fck[0] != 0) {
      m = x - 1;
      n = y - 1;
      if (arr[m] > fck[n]) {
        arr[m + 1] = fck[n];
        fck[n] = 0;
        x++;
        y--;
        mergeSort(arr, 0, x - 1);
      }
      if (arr[m] < fck[n]) {
        fck[n + 1] = arr[m];
        arr[m] = 0;
        y++;
        x--;
        mergeSort(fck, 0, y - 1);
      }
      if (arr[0] == 0) {
        printf("NO\n");
      }
      if (fck[0] == 0) printf("YES\n");
    }
  }
  return 0;
}
