#include <bits/stdc++.h>
using namespace std;
const int N = 100009;
int t, n, k1, k2, a[N], b[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n >> k1 >> k2;
    for (int i = 0; i < k1; ++i) cin >> a[i];
    for (int i = 0; i < k2; ++i) cin >> b[i];
    sort(a, a + k1);
    sort(b, b + k2);
    if (a[k1 - 1] > b[k2 - 1])
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
