#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    int n, k1, k2;
    scanf("%d %d %d", &n, &k1, &k2);
    int maior = 0, win = 1, aux;
    for (int z = 0; z < k1; z++) {
      scanf("%d", &aux);
      maior = max(aux, maior);
    }
    for (int z = 0; z < k2; z++) {
      scanf("%d", &aux);
      if (aux > maior) win = 0;
    }
    if (win)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
