#K81972. Count String Occurrences

    ID: 35872 Type: Default 1000ms 256MiB

Count String Occurrences

Count String Occurrences

You are given two lists of strings. The first list contains n strings, and the second list contains m query strings. For each query string, you are required to count how many times it appears in the list of strings.

Formally, let \( S = [s_1, s_2, \dots, s_n] \) be the list of strings and \( Q = [q_1, q_2, \dots, q_m] \) be the list of queries. For each query \( q_i \), output the value of \( count(q_i) \), where \( count(q_i) \) is the number of times \( q_i \) appears in \( S \).

Your solution should read the input from standard input (stdin) and write the output to standard output (stdout).

inputFormat

The input begins with a line containing two integers n and m, where n is the number of strings and m is the number of queries.

The following n lines each contain a single string representing the elements of the list.

The next m lines each contain a single string representing a query.

outputFormat

Output a single line containing m integers separated by spaces. Each integer represents the count of the corresponding query string in the list of strings.

## sample
5 3
apple
banana
apple
orange
banana
apple
banana
grape
2 2 0