#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, k1, k2;
    cin >> n >> k1 >> k2;
    bool flag = false;
    for (long long i = 0; i < k1; i++) {
      long long x;
      cin >> x;
      if (x == n) {
        flag = true;
      }
    }
    for (long long i = 0; i < k2; i++) {
      long long x;
      cin >> x;
    }
    if (flag) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
