| Codeforces Round 1113 (Div. 2) |
|---|
| Finished |
You are given two arrays $$$a$$$ and $$$b$$$ of lengths $$$n$$$ and $$$m$$$, respectively. All $$$n + m$$$ integers in these arrays are distinct.
You can perform the following operation on $$$a$$$ any number of times (possibly, zero):
After performing all operations, you may arrange the elements of $$$a$$$ in any order.
Determine whether it is possible to make $$$a$$$ equal to $$$b$$$.
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 \le n, m \le 2 \cdot 10^5$$$) — the lengths of the arrays $$$a$$$ and $$$b$$$.
The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^9$$$).
The third line contains $$$m$$$ integers $$$b_1, b_2, \ldots, b_m$$$ ($$$1 \le b_i \le 10^9$$$).
It is guaranteed that all $$$n + m$$$ integers in the arrays $$$a$$$ and $$$b$$$ are distinct.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
It is guaranteed that the sum of $$$m$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, print "YES" if it is possible to make $$$a$$$ equal to $$$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.
112 11 323 21 3 52 44 21 3 5 74 64 22 5 8 111 104 21 4 7 93 105 210 1 100 6 490 56 31 4 10 20 30 403 15 354 21 2 3 1004 57 31 8 3 30 18 12 252 15 284 11 2 3 544 21 3 5 62 4
YESNOYESNONOYESYESNOYESYESYES
In the first test case, choose $$$1$$$ and $$$3$$$, delete them, and insert $$$2$$$.
In the second test case, it can be shown that no sequence of operations can make $$$a$$$ equal to $$$b$$$.
In the third test case, choose $$$1$$$ and $$$5$$$, delete them, and insert $$$4$$$. Then, choose $$$3$$$ and $$$7$$$, delete them, and insert $$$6$$$.
In the sixth test case, first choose $$$1$$$ and $$$10$$$, delete them, and insert $$$5$$$. Next, choose $$$6$$$ and $$$100$$$, delete them, and insert $$$90$$$. Finally, choose $$$4$$$ and $$$5$$$, delete them, and insert $$$5$$$.
In the seventh test case, for the pairs $$$(1,4)$$$, $$$(10,20)$$$, and $$$(30,40)$$$, delete both elements and insert $$$3$$$, $$$15$$$, and $$$35$$$, respectively.
In the ninth test case, delete the pairs $$$(1,3)$$$, $$$(8,18)$$$, and $$$(25,30)$$$ and insert $$$2$$$, $$$15$$$, and $$$28$$$, respectively. Then, delete $$$12$$$ and $$$15$$$ and insert $$$15$$$.
In the tenth test case, first choose $$$1$$$ and $$$2$$$, delete them, and insert $$$2$$$. Then, choose $$$2$$$ and $$$3$$$, delete them, and insert $$$3$$$. Finally, choose $$$3$$$ and $$$5$$$, delete them, and insert $$$4$$$.
| Name |
|---|


