#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
int n, n1, n2, x, T;
int work() {
  scanf("%d%d%d", &n, &n1, &n2);
  for (int i = 0; i < n1; ++i) {
    scanf("%d", &x);
    if (x == n) {
      printf("Yes\n");
    }
  }
  for (int i = 0; i < n2; ++i) {
    scanf("%d", &x);
    if (x == n) {
      printf("No\n");
    }
  }
  return 0;
}
int main() {
  scanf("%d", &T);
  while (T--) work();
  return 0;
}
