public static void main(String[] args) throws IOException {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = new StringTokenizer("");
        PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(out)));

        int T = nextInt();
        for (int t = 0; t < T; t++) {
            int N = nextInt();
            int M = nextInt();
            int[] boys = new int[N];
            int[] girls = new int[M];
            for (int n = 0; n < N; n++) {
                boys[n] = nextInt();
            }
            for (int m = 0; m < M; m++) {
                girls[m] = nextInt();
            }

            if (boys.length > girls.length) {
                pw.println("NO");
            } else {
                Arrays.sort(boys);
                Arrays.sort(girls);

                int girlIndex = 0;
                boolean foundAll = true;
                for (int i = 0; i < N; i++) {
                    int boy = boys[i];
                    boolean found = false;
                    while (girlIndex < M) {
                        if (boy > girls[girlIndex]) {
                            found = true;
                            girlIndex++;
                            break;
                        }
                        girlIndex++;

                    }
                    if (!found) {
                        pw.println("NO");
                        foundAll = false;
                        break;
                    }
                }
                if (foundAll) {
                    pw.println("YES");
                }
            }


        }


        reader.close();
        pw.close();
    }