欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1547C.Pair Programming
Pair Programming
Monocarp and Polycarp are learning new programming techniques. Now they decided to try pair programming.
It's known that they have worked together on the same file for minutes. Every minute exactly one of them made one change to the file. Before they started, there were already lines written in the file.
Every minute exactly one of them does one of two actions: adds a new line to the end of the file or changes one of its lines.
Monocarp worked in total for minutes and performed the sequence of actions . If , then he adds a new line to the end of the file. If , then he changes the line with the number . Monocarp performed actions strictly in this order: , then , ..., .
Polycarp worked in total for minutes and performed the sequence of actions . If , then he adds a new line to the end of the file. If , then he changes the line with the number . Polycarp performed actions strictly in this order: , then , ..., .
Restore their common sequence of actions of length such that all actions would be correct — there should be no changes to lines that do not yet exist. Keep in mind that in the common sequence Monocarp's actions should form the subsequence and Polycarp's — subsequence . They can replace each other at the computer any number of times.
Let's look at an example. Suppose . Monocarp first changed the line with the number and then added a new line (thus, ). Polycarp first added a new line and then changed the line with the number (thus, ).
Since the initial length of the file was , in order for Polycarp to change line number two new lines must be added beforehand. Examples of correct sequences of changes, in this case, would be and . Changes (wrong order of actions) and (line cannot be edited yet) are not correct.
Input
The first line contains an integer (). Then test cases follow. Before each test case, there is an empty line.
Each test case contains three lines. The first line contains three integers , , (, ) — the initial number of lines in file and lengths of Monocarp's and Polycarp's sequences of changes respectively.
The second line contains integers ().
The third line contains integers ().
Output
For each test case print any correct common sequence of Monocarp's and Polycarp's actions of length or -1 if such sequence doesn't exist.
Samples
5
3 2 2
2 0
0 5
4 3 2
2 0 5
0 6
0 2 2
1 0
2 3
5 4 4
6 0 8 0
0 7 0 9
5 4 1
8 7 8 0
0
2 0 0 5
0 2 0 6 5
-1
0 6 0 7 0 8 0 9
-1
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |