#C2332. Merge and Sort Tasks

    ID: 45637 Type: Default 1000ms 256MiB

Merge and Sort Tasks

Merge and Sort Tasks

You are given two lists of tasks. Your goal is to merge them, remove duplicate tasks (ignoring case), and then output the list of unique tasks sorted in a case‐insensitive order. Two tasks are considered duplicates if their lowercase representations are identical. When duplicates occur, the first occurrence (from the input order) is preserved.

Mathematically, if the two input lists are A and B, then the merged list is given by
$$merged = A \cup B$$
After removing duplicates, the final sorted list is obtained as
$$result = \text{sort}(unique,, \text{key}=lower)$$

inputFormat

The input is read from standard input (stdin). It is formatted as follows:
• The first line contains an integer N1, representing the number of tasks in the first list.
• The next N1 lines each contain a task (which may include spaces).
• The following line contains an integer N2, representing the number of tasks in the second list.
• The next N2 lines each contain a task.

Note: There is no extra whitespace at the beginning or the end of each line.

outputFormat

Print the unique tasks in sorted order, one task per line, to standard output (stdout). The sorting should be performed in a case-insensitive manner.## sample

3
Buy Groceries
Clean the house
do laundry
3
do laundry
Feed the cat
buy groceries
Buy Groceries

Clean the house do laundry Feed the cat

</p>