Rock is going to host two sessions of yoga classes. The first session has $N$ students, and the second session has $M$ students. Each student has a unique ID between $1$ and $N + M$.
Rock made a list of students of each of his classes, with the students' IDs in sorted order. He noticed that some students have enrolled in both classes, when he told them to enrol in at most one! Help Rock remove such students from both classes, and determine the new class lists (also in sorted order).
Input
The first line contains two integers $N$ and $M$, the sizes of the two classes respectively.
The second line contains $N$ integers, the list of students in the first class.
The third line contains $M$ integers, the list of students in the second class.
Output
On the first line, output the resulting list of students in the first class (sorted).
On the second line, output the resulting list of students in the second class (sorted).
Subtasks
Subtask 1 (25%): $1 \le N, M \le 50$
Subtask 2 (25%): $1 \le N, M \le 2000$
Subtask 3 (50%): $1 \le N, M \le 10^5$
Sample Test Cases
Input | Output | |
---|---|---|
5 7 2 5 6 9 11 1 2 3 6 7 10 11 |
5 9 1 3 7 10 |
|
Students 2, 6 and 11 are enrolled in both classes, so they are removed. |
Scoring: Per Subtask
Authored by s16f22
Appeared in 2023 Mini Contest 4