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