#C7457. Word Count in Text Block

    ID: 51330 Type: Default 1000ms 256MiB

Word Count in Text Block

Word Count in Text Block

In this problem, you are given a list of words and a block of text. Your task is to count the occurrence of each word from the list in the text. The words are case-insensitive, and punctuation should be ignored. You need to process the text properly using regular expressions, and output the count of each queried word in the order they are given.

Formally, for each word \(w\) in the list, find the number of occurrences of \(w\) in the text. Here, a word is defined by the regex pattern \(\texttt{\\b\\w+\\b}\). This means that every contiguous sequence of alphanumeric characters is treated as a word.

inputFormat

The input is received via standard input in the following format:

  1. An integer \(N\) representing the number of words to be counted.
  2. A line containing \(N\) space-separated words.
  3. An integer \(M\) representing the number of lines in the text block.
  4. \(M\) lines of text.

outputFormat

Print the counts of each word in the order they were given, separated by a single space, to standard output.

## sample
3
hello world example
2
hello! world. this is an example.
is this the example, or another example?
1 1 3