#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  for (int i = 0; i < T; i++) {
    int n, a1, a2;
    bool flag = true;
    vector<int> a1s, a2s;
    cin >> n >> a1 >> a2;
    for (int i = 0; i < a1; i++) {
      int tmp;
      cin >> tmp;
      if (tmp == n) {
        cout << "YES" << endl;
        flag = false;
      }
    }
    for (int i = 0; i < a2; i++) {
      int tmp;
      cin >> tmp;
    }
    if (flag) {
      cout << "NO" << endl;
    }
  }
  return 0;
}
