#K61257. Add Item to Shopping List

    ID: 31269 Type: Default 1000ms 256MiB

Add Item to Shopping List

Add Item to Shopping List

You are given a shopping list containing n items and a new item. Your task is to add the new item to the shopping list if it does not already exist (comparison is case-insensitive). After processing, output the shopping list in sorted order (using case-insensitive sorting) while retaining the original cases of the items.

Note: If the item already exists in the list (ignoring case), do not add it, and simply output the original list sorted in case-insensitive order.

The sorting order is determined exclusively by the lowercase form of each string. That is, for any two strings \(a\) and \(b\), you should arrange them so that \(\text{lower}(a) < \text{lower}(b)\).

inputFormat

The input consists of several lines:

  1. The first line contains an integer \(n\) denoting the number of items in the current shopping list.
  2. The next \(n\) lines each contain a string that represents an item in the shopping list. (The items contain no spaces.)
  3. The following line contains a string representing the new item that you may need to add.

For example:

3
Apples
bananas
Carrots
dates

outputFormat

Output a single line with the updated shopping list items, sorted in case-insensitive order, separated by a single space.

For the sample input above, the output should be:

Apples bananas Carrots dates
## sample
3
Apples
bananas
Carrots
dates
Apples bananas Carrots dates