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