#K10006. Keyword Frequency Analysis

    ID: 23150 Type: Default 1000ms 256MiB

Keyword Frequency Analysis

Keyword Frequency Analysis

You are given a list of keywords and a list of documents. Each document is a string consisting of words separated by spaces. Your task is to compute the frequency of each keyword across all documents.

For a given keyword \( k \), its frequency is computed as follows:

\( freq(k) = \sum_{i=1}^{M} count(k, d_i) \)

where \( count(k, d_i) \) is the number of times keyword \( k \) appears in document \( d_i \), and \( M \) is the total number of documents.

Note: The matching is case-sensitive and words in documents are separated by whitespace.

inputFormat

The input is read from standard input (stdin) and is structured as follows:

  1. An integer \( N \) representing the number of keywords.
  2. \( N \) lines each containing a keyword.
  3. An integer \( M \) representing the number of documents.
  4. \( M \) lines each containing a document (a string that may contain spaces).

All inputs are provided in the order described.

outputFormat

Print a single line to standard output (stdout) containing \( N \) integers separated by a single space. Each integer represents the total frequency count of the corresponding keyword in the input order.

## sample
3
keyword1
keyword2
keyword3
2
this is a document containing keyword1 and another keyword1
another document with keyword2
2 1 0