#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(vector<T> &a, long long n) {
  T x;
  a.clear();
  for (long long i = 0; i < n; i++) {
    cin >> x;
    a.push_back(x);
  }
}
template <class T>
void write(vector<T> &a) {
  for (T x : a) cout << x << " ";
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  int T;
  cin >> T;
  while (T--) {
    int n, m;
    vector<int> a, b;
    cin >> n >> n >> m;
    read(a, n);
    read(b, m);
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if (a.back() > b.back())
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
