Universal Cup Judging System

Universal Cup

Time Limit: 2.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓
Statistics

Randias 正在玩一个游戏。他有两个多重集(可以包含重复元素)$A$ 和 $B$,分别包含 $n$ 个整数 $A_1, A_2, \dots, A_n$ 和 $m$ 个整数 $B_1, B_2, \dots, B_m$。他可以进行任意次数的以下操作:

  • 选择一个元素 $x \in A$,将 $x$ 变为 $x + 1$。然后移除 $A$ 中的最小元素。注意,如果 $A$ 中有多个最小元素,我们只移除其中一个。

例如,如果 $A = \{4, 4, 5, 5, 6\}$ 且我们选择 $x = 5$,操作后 $A$ 将变为 $\{4, 5, 6, 6\}$。

他想知道是否可以通过若干次(可能为零次)操作使得 $A = B$?如果可以,请帮助他确定需要执行哪些操作。

如果对于所有 $x$,集合 $A$ 和 $B$ 中 $x$ 出现的次数相同,则认为这两个多重集相等。

输入格式

第一行包含一个整数 $t$ ($1 \le t \le 5 \cdot 10^4$),表示测试用例的数量。

对于每个测试用例,第一行包含两个整数 $n, m$ ($1 \le m \le n \le 3 \cdot 10^5$),表示两个多重集的大小。

接下来一行包含 $n$ 个整数 $A_1, A_2, \dots, A_n$ ($1 \le A_i \le 10^9$)。

接下来一行包含 $m$ 个整数 $B_1, B_2, \dots, B_m$ ($1 \le B_i \le 10^9$)。

保证所有测试用例中 $n$ 的总和与 $m$ 的总和均不超过 $3 \cdot 10^5$。

输出格式

对于每个测试用例,如果 Randias 无法使 $A = B$,输出 “$-1$”。

否则,在第一行输出 Randias 需要执行的操作次数 $L$ ($0 \le L \le n$)。

下一行包含 $L$ 个整数 $x_1, x_2, \dots, x_L$,表示每次操作所选择的整数 $x$。你必须确保在每次操作前 $x \in A$。

如果存在多种方案,输出任意一种即可。

样例

样例输入 1

6
5 3
1 2 2 3 3
2 3 4
4 2
1 2 2 4
2 4
5 2
2 3 3 4 4
5 5
6 1
1 1 1 1 1 1
4
4 2
1 1 1 2
2 2
4 1
1 1 1 1
2

样例输出 1

2
1 3
-1
3
2 4 4
5
1 1 1 2 3
2
1 1
-1

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.