#include <bits/stdc++.h>
using namespace std;
int n, n1, n2, Max1, Max2;
inline int in() {
  char c;
  int f = 1;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') f = -1;
  int x = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0';
  return x * f;
}
int main() {
  int t = in();
  while (t--) {
    n = in(), n1 = in(), n2 = in(), Max1 = Max2 = 0;
    for (int i = 1; i <= n1; ++i) Max1 = max(Max1, in());
    for (int i = 1; i <= n2; ++i) Max2 = max(Max2, in());
    puts(Max1 < Max2 ? "NO" : "YES");
  }
  return 0;
}
