#include <bits/stdc++.h>
int N, M, i, j, L, len, sum, Ans, F, G;
int p[2005], f[2005], g[2005], l[2005];
int h[1000005][30];
char s[1000005], temp[1000005], t[2005];
void find(char ch, int f, int g, int &F, int &G) {
  if (f != 0 && p[l[f]] + g + 1 < p[l[f] + 1])
    ++g;
  else
    ++f, g = 0;
  if (f > M) {
    F = -1;
    return;
  }
  for (; h[p[l[f]] + g][ch - 'a'] == -1 && f <= M; ++f) g = 0;
  if (f > M) {
    F = -1;
    return;
  }
  F = f;
  G = h[p[l[f]] + g][ch - 'a'] - p[l[f]];
}
int main() {
  memset(h, -1, sizeof(h));
  scanf("%d", &N);
  for (i = 1; i <= N; ++i) {
    scanf("%s", temp);
    L = strlen(temp);
    p[i] = sum, sum += L;
    for (j = 0; j < L; ++j) s[p[i] + j] = temp[j];
    for (j = sum - 1; j >= p[i]; --j) {
      if (j != sum - 1) memcpy(h[j], h[j + 1], sizeof(h[j]));
      h[j][s[j] - 'a'] = j;
    }
  }
  p[N + 1] = sum;
  scanf("%d", &M);
  for (i = 1; i <= M; ++i) scanf("%d", &l[i]);
  scanf("%s", t);
  len = strlen(t);
  memset(f, -1, sizeof(f));
  f[0] = g[0] = 0;
  for (i = 0; i < len; ++i) {
    for (j = Ans; j >= 0; --j) {
      find(t[i], f[j], g[j], F, G);
      if (F == -1) continue;
      if (f[j + 1] == -1 || F < f[j + 1] || F == f[j + 1] && G < g[j + 1])
        f[j + 1] = F, g[j + 1] = G;
    }
    if (f[Ans + 1] != -1) ++Ans;
  }
  printf("%d\n", Ans);
  return 0;
}
