#C106. Count Word Occurrences

    ID: 39822 Type: Default 1000ms 256MiB

Count Word Occurrences

Count Word Occurrences

Given an integer \(N\) representing the number of words, a list of \(N\) words, and a text document, your task is to count the number of times each word appears in the text. The text consists of space-separated words. Output the counts for each word in the same order as they appear in the given list.

For example, if \(N=3\), words are "hello", "world", "lorem" and the text is "hello world this is a hello world example of lorem ipsum text", then the counts are 2 2 1.

inputFormat

The input is read from standard input (stdin) and consists of three lines:

  1. The first line contains an integer \(N\), the number of words to count.
  2. The second line contains \(N\) words separated by spaces.
  3. The third line contains a text document, which is a sequence of space-separated words.

outputFormat

Output \(N\) integers separated by a space to standard output (stdout), where each integer represents the count of the corresponding word (in the given order) in the text document.

## sample
3
hello world lorem
hello world this is a hello world example of lorem ipsum text
2 2 1