1852 GongDui背单词


Submit solution

Points: 100
Time limit: 1.0s
Memory limit: 32M

Problem types
Allowed languages
C, C++, Java, Python

Description

GongDui为了去大美利坚成就一番事业每天勤勤恳恳地背着单词,,现在请你帮忙统计一下,对于各种前缀,龚对已经背了多少单词了.

Input

第一行一个整数n(n<=10000)代表GongDui已经背过的单词的数量 余下n行,每行一个单词,长度10以内,不重复,仅小写字母 另起一行,一个整数m(m<1000),代表各种前缀的数量,仅小写字母 余下m行,每行一个词头,长度10以内

Output

对于每个前缀,输出一行整数,代表此前缀的单词龚对已经背了多少

Sample

Input

7
apple
apply
banana
beautiful
girl
sexy
lady
3
a
b
girl

Output

2
2
1

Source: Renkai


Comments

There are no comments at the moment.