Jong Hyok and String

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

Jong Hyok loves strings consisting of lowercase English letters. One day, he gave a problem to his friend, which happened to be... you! He wrote down nn strings P_1P\_1, P_2P\_2, \ldots, P_nP\_n in front of you, and then asked mm questions.

Consider a string SS. Define the StrangeSet(S)\mathit{StrangeSet} (S) as the set of all pairs (i,j)(i, j) such that SS occurs in P_iP\_i as a substring ending at position jj.

When asking question number kk, Jong Hyok gives you a string Q_kQ\_k. You must find the number of different strings TT such that StrangeSet(Q_k)=StrangeSet(T)\mathit{StrangeSet} (Q\_k) = \mathit{StrangeSet} (T) and TT is a substring of at least one of the given nn strings.

입력

The first line of input contains two integers nn and mm (1n1051 \le n \le 10^5, 1m51051 \le m \le 5 \cdot 10^5).

The next nn lines contain strings P_1P\_1, P_2P\_2, \ldots, P_nP\_n, one per line (1P_i1051 \le |P\_i| \le 10^5).

The following mm lines contain strings Q_1Q\_1, Q_2Q\_2, \ldots, Q_mQ\_m, one per line (1Q_k1051 \le |Q\_k| \le 10^5).

All n+mn + m strings consist of lowercase English letters.

The sum of all P_i|P\_i| in the input does not exceed 10510^5.

The sum of all P_i|P\_i| and all Q_k|Q\_k| in the input is at most 21062 \cdot 10^6.

출력

For each question, print one integer on a separate line: the answer to this question.