#include <bits/stdc++.h>
using namespace std;
int n, total, first, second;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> total >> first >> second;
    int temp;
    bool flag = false;
    for (int j = 0; j < first; j++) {
      cin >> temp;
      if (temp == total) {
        flag = true;
      }
    }
    for (int j = 0; j < second; j++) {
      cin >> temp;
    }
    if (!flag)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
