#K12671. Merge and Sort Books

    ID: 23743 Type: Default 1000ms 256MiB

Merge and Sort Books

Merge and Sort Books

You are given T test cases. For each test case, you are given two lists of book IDs. The first list contains N integers and the second list contains M integers. Your task is to merge these two lists, remove duplicates, and output the sorted order of the unique book IDs.

The operation performed is essentially the union of the two sets, followed by sorting in ascending order (i.e., (A \cup B) followed by sorting).

inputFormat

The input comes from stdin. The first line contains an integer T, representing the number of test cases. Each test case consists of three lines:

  1. The first line contains two space-separated integers N and M.
  2. The second line contains N space-separated integers (the first list of book IDs).
  3. The third line contains M space-separated integers (the second list of book IDs).

outputFormat

For each test case, output a single line containing the sorted, unique book IDs separated by a single space. The output should be printed to stdout.## sample

1
3 4
10 20 30
20 40 50 60
10 20 30 40 50 60

</p>