IAEPC Preliminary Contest (Codeforces Round 999, Div. 1 + Div. 2)
D
Kevin and Numbers
Codeforces
1600
原题
← CE →
翻译中…

Kevin wrote an integer sequence $a$ of length $n$ on the blackboard.

翻译中…

Kevin can perform the following operation any number of times:

翻译中…
  • Select two integers $x, y$ on the blackboard such that $|x - y| \leq 1$, erase them, and then write down an integer $x + y$ instead.
翻译中…

Kevin wants to know if it is possible to transform these integers into an integer sequence $b$ of length $m$ through some sequence of operations.

翻译中…

Two sequences $a$ and $b$ are considered the same if and only if their multisets are identical. In other words, for any number $x$, the number of times it appears in $a$ must be equal to the number of times it appears in $b$.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The first line of each test case contains two integers $n$ and $m$ ($1\leq m \leq n \leq 2\cdot 10^5$) — the length of $a$ and the length of $b$.

翻译中…

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1\leq a_i \leq 10^9$).

翻译中…

The third line contains $m$ integers $b_1, b_2, \ldots, b_m$ ($1\leq b_i \leq 10^9$).

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $2\cdot 10^5$.

翻译中…

Output

翻译中…

For each test case, output "Yes" if it is possible to transform $a$ into $b$, and "No" otherwise.

翻译中…

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

翻译中…

Note

翻译中…

In the first test case, you can erase $4, 5$, and write down $9$.

翻译中…

In the second test case, you can't erase $3, 6$.

翻译中…

In the third test case, one possible way could be:

翻译中…
  • Erase $2, 2$, and write down $4$. The remaining numbers are $1, 2, 4$ now.
  • Erase $1, 2$, and write down $3$. The remaining numbers are $3, 4$ now.
翻译中…

In the fourth test case, one possible way could be:

翻译中…
  • Erase $1, 1$, and write down $2$. The remaining numbers are $2, 3, 3$ now.
  • Erase $2, 3$, and write down $5$. The remaining numbers are $3, 5$ now.
翻译中…

样例

Input #1
9
2 1
4 5
9
2 1
3 6
9
4 2
1 2 2 2
3 4
4 2
1 1 3 3
3 5
4 2
1 2 3 4
3 5
5 5
1 2 3 4 5
5 4 3 2 1
4 2
1 1 1 1
1 1
4 4
1 1 1 1
1 1 1 2
1 1
1
1000000000
Output #1
Yes
No
Yes
Yes
No
Yes
No
No
No
InputCopy OutputCopy
题目信息
题号
2061D
时间限制
2 s
内存限制
256 MB
标签
位运算
数据结构

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。