#P10470. 前缀统计

前缀统计

Problem Description

Given NN strings S1,S2,,SNS_1,S_2,\cdots,S_N, you will then make MM queries. In each query, a string TT is given. Find how many strings among S1SNS_1 \sim S_N are prefixes of TT.

The total length of all input strings does not exceed 10610^6, and they contain only lowercase letters.

Input Format

The first line contains two integers N,MN,M.

The next NN lines each contain a string SiS_i.

The next MM lines each contain a string TT for querying.

Output Format

For each query, output an integer representing the answer.

Each answer occupies one line.

3 2
ab
bc
abc
abc
efg
2
0

Hint

Constraints: 1N,M1051 \le N,M \le 10^5.

Translated by ChatGPT 5