#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, n, m;
  int round;
  scanf("%d", &round);
  while (round--) {
    scanf("%d%d%d", &x, &n, &m);
    int t;
    for (int i = 0; i < n; i++) {
      scanf("%d", &t);
      if (t == x) {
        puts("YES");
      }
    }
    for (int i = 0; i < m; i++) {
      scanf("%d", &t);
      if (t == x) {
        puts("NO");
      }
    }
  }
  return 0;
}
