#K49262. Dictionary Antonym Manager

    ID: 28604 Type: Default 1000ms 256MiB

Dictionary Antonym Manager

Dictionary Antonym Manager

You are required to implement a program that manages a dictionary containing word-antonym pairs in a case-insensitive manner. The program should support the following commands:

  • ADD word antonym: Add a word and its antonym to the dictionary. If the word already exists (ignoring case), update its antonym.
  • GET word: Retrieve and print the antonym of the provided word. If the word does not exist in the dictionary, print None.
  • REMOVE word: Remove the word (and its antonym) from the dictionary and print the removed antonym. If the word is not present, print None.
  • LIST: Print all word-antonym pairs sorted alphabetically by the word. For each pair, print the word and its antonym separated by a space on a separate line. If the dictionary is empty, print an empty line.

The input will be provided via standard input (stdin) and the outputs must be printed to standard output (stdout).

Note: All word comparisons should be case-insensitive. Internally, you can convert words to lower-case to ensure consistency.

The mathematical description of the case-insensitivity transformation can be represented as: $$ word' = \text{lower}(word) $$

inputFormat

The first line contains a single integer Q, the number of commands. The following Q lines each contain a command which can be one of the following:

  • ADD word antonym
  • GET word
  • REMOVE word
  • LIST

Each command and its parameters are space separated.

outputFormat

For each command that requires an output (GET, REMOVE, and LIST), print the result on standard output (stdout). For GET and REMOVE, print a single line with the corresponding result or None if applicable. For the LIST command, print each word-antonym pair on a new line in the format "word antonym". If there are no pairs in the dictionary, print an empty line.

## sample
5
GET hot
ADD hot cold
GET hot
ADD big small
LIST
None

cold big small hot cold

</p>