#x1054. CF587F Duff is Mad
CF587F Duff is Mad
Duff is Mad
题面翻译
- 给定 个字符串 。
- 次询问 在 中出现了多少次。
- 。
题目描述
Duff is mad at her friends. That's why she sometimes makes Malek to take candy from one of her friends for no reason!
She has friends. Her -th friend's name is (their names are not necessarily unique). times, she asks Malek to take candy from her friends. She's angry, but also she acts with rules. When she wants to ask Malek to take candy from one of her friends, like , she chooses two numbers and and tells Malek to take exactly
candies from him/her, where is the number of occurrences of string in .
Malek is not able to calculate how many candies to take in each request from Duff. That's why she asked for your help. Please tell him how many candies to take in each request.
输入格式
The first line of input contains two integers and ( ).
The next lines contain the names. -th of them contains an string , consisting of lowercase English letters ().
The next lines contain the requests. Each of them contains three integers, and (says that Malek should take candies from Duff's -th friend).
输出格式
Print the answer to each request in one line.
样例 #1
样例输入 #1
5 5
a
ab
abab
ababab
b
1 5 4
3 5 4
1 5 2
1 5 3
1 4 1
样例输出 #1
12
6
3
7
1