Universal Cup Judging System

Universal Cup

Time Limit: 1.0 s Memory Limit: 1024 MB Total points: 100 Difficulty: [show] Hackable ✓
Statistics

Little Cyan Fish 最近踏上了一段探索最小值和最大值概念的旅程。今天,他发现了一个整数序列 $a_1, a_2, \dots, a_n$。他可以随时执行以下两种操作:

  • 选择序列中两个相邻的元素 $x$ 和 $y$,将它们合并为一个等于 $\min(x, y)$ 的元素。
  • 选择序列中两个相邻的元素 $x$ 和 $y$,将它们合并为一个等于 $\max(x, y)$ 的元素。

当合并两个相邻元素时,这两个元素将从序列中移除,新的元素将被插入到这两个元素原本的位置。

Little Cyan Fish 想要将原始序列 $a_1, a_2, \dots, a_n$ 转换为另一个序列 $b_1, b_2, \dots, b_m$。你的任务是判断是否可以通过一系列操作实现这个目标序列。

输入格式

输入文件包含多个测试用例。输入的第一行包含一个整数 $T$ ($1 \le T \le 10^5$),表示测试用例的数量。

对于每个测试用例,第一行包含两个整数 $n$ 和 $m$ ($1 \le m \le n \le 10^5$)。 下一行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le n$)。 再下一行包含 $m$ 个整数 $b_1, b_2, \dots, b_m$ ($1 \le b_i \le n$)。

保证所有测试用例的 $n$ 之和不超过 $10^5$。

输出格式

对于每个测试用例,如果可以将序列转换成功,输出一行 Yes。否则,输出一行 No

样例

样例输入 1

3
2 1
1 2
1
5 4
1 1 1 1 1
1 1 2 1
10 5
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10

样例输出 1

Yes
No
Yes

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.