#include <bits/stdc++.h>
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, k1, k2;
    scanf("%d%d%d", &n, &k1, &k2);
    int arr1[k1];
    int arr2[k2];
    int i;
    for (i = 0; i < k1; i++) scanf("%d", &arr1[i]);
    for (i = 0; i < k2; i++) scanf("%d", &arr2[i]);
    for (i = 0; i < k1; i++) {
      if (arr1[i] == n) printf("YES\n");
    }
    for (i = 0; i < k2; i++) {
      if (arr2[i] == n) printf("NO\n");
    }
  }
  return 0;
}
