#include <bits/stdc++.h>
using namespace std;
int p, k, n;
string s, word[1005], sum[1005][1005];
bool check(int l, int r)
{
string f = s.substr(l, r - l - 1);
for (int i = 1; i <= n; i++)
{
if(s.find(word[i]) == 0) return true;
else return false;
}
}
int main()
{
cin >> p >> k;
s += '#';
for (int i = 1; i <= n; i++)
{
string s1;
cin >> s1;
s += s1;
}
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> word[i];
}
int h = s.size() - 1;
for (int i = h; i >= 0; i--)
{
for (int j = i; j >= 0; j--)
{
sum[j][i] = sum[j - 1][i];
if (check(i, j))
{
sum[j - 1][i]++;
}
}
}
return 0;
}