#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k1, k2, arrk1[10000], arrk2[10000];
    cin >> n >> k1 >> k2;
    int x = 0, y = 0;
    for (int i = 1; i <= k1; i++) {
      scanf("%d", &arrk1[i]);
      if (arrk1[i] > x) {
        x = arrk1[i];
      }
    }
    for (int j = 1; j <= k2; j++) {
      scanf("%d", &arrk2[j]);
      if (arrk2[j] > y) {
        y = arrk2[j];
      }
    }
    if (x > y) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }
  return 0;
}
