#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k1, k2;
    cin >> n >> k1 >> k2;
    int f1 = 0;
    int f2 = 0;
    for (int i = 0; i < k1; i++) {
      int p;
      cin >> p;
      if (p == n) {
        f1 = 1;
      }
    }
    for (int i = 0; i < k2; i++) {
      int p;
      cin >> p;
      if (p == n) {
        f2 = 1;
      }
    }
    if (f1) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
