#P2336. Cat Alien Attendance
Cat Alien Attendance
Cat Alien Attendance
In this problem, there are (n) cat aliens, each with a surname and a given name represented as strings of digits. A teacher calls out (m) number strings. For each call-out string, if it appears as a substring in either the surname or given name of a cat alien, that alien must answer. Your task is to report two things:\
- For each call-out, the number of aliens that answer.\
- After all (m) call-outs, the total number of times each alien has answered.\ \ A substring is defined in the usual way, e.g. string (s) is a substring of string (t) if (s) can be obtained by deleting some (possibly zero) characters from the beginning of (t) and some (possibly zero) characters from the end of (t).
inputFormat
The first line contains two integers (n) and (m) (the number of cat aliens and the number of call-outs).\ Each of the next (n) lines contains two non-empty strings denoting the surname and given name of a cat alien.\ Each of the following (m) lines contains a non-empty string representing a call-out value.
outputFormat
For each call-out, output the number of cat aliens that answer, each on a separate line.\ After that, output one line with (n) integers separated by a space, where the (i)-th integer represents the total number of times the (i)-th cat alien answered over the (m) call-outs.
sample
3 3
123 4567
12 789
345 678
2
456
78
2
1
2
2 2 1
</p>