#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
using namespace std;
long long powmod(long long a, long long b) {
  long long res = 1ll;
  while (b) {
    if (b & 1) res = (res * a) % MOD;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, k1, k2;
    cin >> n >> k1 >> k2;
    int tmp;
    bool state = false;
    for (int i = 0; i < k1; i++) cin >> tmp, state |= tmp == n;
    for (int i = 0; i < k2; i++) cin >> tmp;
    if (state)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
