B - Invalid Vote 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 200 点

問題文

選挙に N 人の候補者 1,2,\dots,N が立候補しています。 各候補者の名前は英小文字からなり、互いに異なります。 候補者 i の名前は S_i です。

M 枚の投票用紙 1,2,\dots,M が投じられ、投票用紙 j には英小文字からなる文字列 T_j が書かれていました。

T_j が名前に完全に一致している候補者がいる場合、その候補者に 1 票が入ります。 そうでなく、T_j を 1 文字書き換えて名前が一致するような候補者がちょうど 1 人いる場合、その候補者に 1 票が入ります。 そうでない場合、それは無効票となります。

i=1,2,\dots,N について、候補者 i に何票入るかを求めてください。

制約

  • 1 \leq N \leq 100
  • 1 \leq M \leq 100
  • 1 \leq |S_i| \leq 10
  • i \neq j ならば S_i \neq S_j
  • 1 \leq |T_j| \leq 10
  • S_i,T_j は英小文字からなる文字列
  • N と M は整数

入力

入力は以下の形式で標準入力から与えられる。

N M  
S_1  
S_2  
\vdots  
S_N  
T_1  
T_2  
\vdots  
T_M  

出力

答えを合計 N 行で出力せよ。
i 行目には、候補者 i に何票入るかを出力せよ。


入力例 1

5 8
takahashi
aoki
sato
kato
kano
aoki
takanashi
sano
atcoder
chokudai
kato
aoki
yato

出力例 1

1
2
0
1
0

takahashi,aoki,sato,kato,kano の 5 人の候補者がいます。
投票用紙 1 には aoki と書かれています。
候補者 2 に 1 票が入ります。

投票用紙 2 には takanashi と書かれています。
5 文字目を n から h に書き換えることで候補者 1 の名前と一致し、またそのような候補者は他にいないため、候補者 1 に 1 票が入ります。

投票用紙 3 には sano と書かれています。
3 文字目を n から t に書き換えることで候補者 3 の名前と一致し、1 文字目を s から k に書き換えることで候補者 5 の名前と一致するため、これは無効票となります。


入力例 2

2 5
a
b
a
b
c
a
aa

出力例 2

2
1

Score : 200 points

Problem Statement

N candidates 1,2,\dots,N are running in an election. The name of each candidate consists of lowercase English letters, and the names are distinct. The name of candidate i is S_i.

M ballots 1,2,\dots,M were cast, and ballot j has a string T_j consisting of lowercase English letters written on it.

If there is a candidate whose name exactly matches T_j, that candidate receives 1 vote. Otherwise, if there is exactly one candidate whose name can be obtained by changing 1 character of T_j, that candidate receives 1 vote. Otherwise, the ballot is invalid.

For each i=1,2,\dots,N, find how many votes candidate i receives.

Constraints

  • 1 \leq N \leq 100
  • 1 \leq M \leq 100
  • 1 \leq |S_i| \leq 10
  • S_i \neq S_j if i \neq j.
  • 1 \leq |T_j| \leq 10
  • S_i and T_j are strings consisting of lowercase English letters.
  • N and M are integers.

Input

The input is given from Standard Input in the following format:

N M  
S_1  
S_2  
\vdots  
S_N  
T_1  
T_2  
\vdots  
T_M  

Output

Print N lines in total.
The i-th line should contain the number of votes candidate i receives.


Sample Input 1

5 8
takahashi
aoki
sato
kato
kano
aoki
takanashi
sano
atcoder
chokudai
kato
aoki
yato

Sample Output 1

1
2
0
1
0

There are 5 candidates: takahashi, aoki, sato, kato, and kano.
Ballot 1 has aoki written on it.
Candidate 2 receives 1 vote.

Ballot 2 has takanashi written on it.
Changing the 5-th character from n to h makes it match the name of candidate 1, and there is no other such candidate, so candidate 1 receives 1 vote.

Ballot 3 has sano written on it.
Changing the 3-rd character from n to t makes it match the name of candidate 3, and changing the 1-st character from s to k makes it match the name of candidate 5, so this ballot is invalid.


Sample Input 2

2 5
a
b
a
b
c
a
aa

Sample Output 2

2
1