#C2402. Sentence Correction

    ID: 45715 Type: Default 1000ms 256MiB

Sentence Correction

Sentence Correction

You are given a sentence and a dictionary of common misspellings. Your task is to replace the misspelled words in the sentence with their correct forms. The matching should be performed in a case‐insensitive manner. That is, if a word in the sentence matches any key in the dictionary (ignoring letter case), then replace that word with the corresponding correct word from the dictionary. Words that are not present in the dictionary should remain unchanged.

For example, given the dictionary \( {\texttt{\"teh\":\"the\", \"recieve\":\"receive\", \"adn\":\"and\", \"definately\":\"definitely\"} \)

and the sentence:
I definately need to chek teh document to recieve corrections.
the output should be:
I definitely need to chek the document to receive corrections.

Please note that only words matching keys in the dictionary are replaced. The replacement is always done with the correct word exactly as provided in the dictionary.

inputFormat

The input is read from stdin and is structured as follows:

  • The first line contains the sentence.
  • The second line contains an integer n, representing the number of misspellings in the dictionary.
  • The following n lines each contain two strings separated by whitespace: the misspelled word and its correct replacement.

Note: The matching should be case-insensitive.

outputFormat

Output the corrected sentence to stdout. Only the words present in the dictionary (matched in a case-insensitive manner) should be replaced.

## sample
I definately need to chek teh document to recieve corrections.
4
teh the
recieve receive
adn and
definately definitely
I definitely need to chek the document to receive corrections.