#include <bits/stdc++.h>
using namespace std;
const int MAXINT = 1073741823;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t, n, a, b, x;
  bool win;
  cin >> t;
  for (int q = 0; q < t; q++) {
    cin >> n >> a >> b;
    win = false;
    for (int i = 0; i < a; i++) {
      cin >> x;
      if (x == n) win = true;
    }
    for (int i = 0; i < b; i++) cin >> x;
    cout << (win ? "YES" : "NO") << '\n';
  }
  return 0;
}
