A. Autocomplete
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Example
Input
5
1 1 2 3
abczz
3
abz
ace
a*z
Output
1
0
2