#include <bits/stdc++.h>
using namespace std;
long long m = 0, n, i, j, x, y, t;
void nhap() {
  cin >> t;
  while (t--) {
    m = 0;
    cin >> n >> x >> y;
    for (i = 1; i <= x; i++) {
      cin >> j;
      if (j == n) cout << "YES" << endl;
    }
    for (i = 1; i <= y; i++) {
      cin >> j;
      if (j == n) cout << "NO" << endl;
    }
  }
}
int main() {
  nhap();
  return 0;
}
