#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, k1, k2;
  cin >> t;
  int a, b, i, j, count1 = 0, count2 = 0;
  while (t--) {
    cin >> n >> k1 >> k2;
    int a[k1], b[k2];
    for (i = 0; i < k1; i++) cin >> a[i];
    sort(a, a + k1);
    for (j = 0; j < k2; j++) cin >> b[j];
    sort(b, b + k2);
    if (a[k1 - 1] > b[k2 - 1]) {
      cout << "YES" << endl;
    } else
      cout << "NO" << endl;
  }
  return 0;
}
