#K12846. Keyword Highlighter

    ID: 23781 Type: Default 1000ms 256MiB

Keyword Highlighter

Keyword Highlighter

Given a document and a list of keywords, your task is to replace every occurrence of each keyword in the document with its highlighted version. The highlighted version is defined as the keyword enclosed in square brackets. The replacement is case sensitive and applied sequentially for each keyword.

For example, if the document is "this is a test document" and the keywords are "test" and "document", the output should be "this is a [test] [document]".

inputFormat

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

  • The first line contains an integer T, the number of test cases.
  • For each test case:
    • The first line contains a string document.
    • The second line contains an integer K, the number of keywords.
    • The following K lines each contain a keyword.

outputFormat

For each test case, output the modified document on a new line to stdout. Each occurrence of any given keyword should be replaced by the same keyword enclosed in square brackets.

## sample
1
hello world
1
world
hello [world]