#C9840. Expand Abbreviations

    ID: 53978 Type: Default 1000ms 256MiB

Expand Abbreviations

Expand Abbreviations

You are given a set of abbreviation-expansion pairs and a number of messages. The task is to expand the abbreviations in each message using the provided mappings.

The input format is as follows:

  • The first line contains an integer \(K\), the number of abbreviations.
  • The next \(K\) lines each contain an abbreviation followed by a colon and its expansion (format: "abbr: expansion").
  • The following line contains an integer \(N\), the number of messages.
  • The next \(N\) lines each contain a message that may include abbreviations.

Your program should replace all occurrences of each abbreviation in every message with its corresponding expansion and output the transformed messages, one per line.

Note that the replacement is done by a simple string substitution (i.e. all occurrences are replaced without considering word boundaries).

inputFormat

The input is read from standard input (stdin). It begins with an integer \(K\) indicating the number of abbreviation mappings. The next \(K\) lines each contain an abbreviation and its expansion separated by a colon and a space. Then, an integer \(N\) indicates the number of messages, followed by \(N\) lines each containing one message.

outputFormat

For each message, output the resulting message after all the abbreviations have been expanded. Each output should be on a separate line, written to standard output (stdout).

## sample
3
brb: be right back
omw: on my way
lol: laugh out loud
2
brb, omw now!
This is so funny lol!
be right back, on my way now!

This is so funny laugh out loud!

</p>