#include <bits/stdc++.h>
const int N = 2005, M = N * 500;
int next[M][26], to[N][26], o[26], w[N], id[N], f[N], g[N], n, m, L, ans, x, y;
char s[M];
int find(char c, int x, int y, int &f, int &g) {
  if (next[w[id[x]] + y][c])
    f = x, g = next[w[id[x]] + y][c];
  else
    f = to[x][c], g = next[w[id[f]]][c];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++, memset(o, 0, sizeof(o))) {
    scanf("%s", s + 1), L = strlen(s + 1), w[i + 1] = w[i] + L + 1;
    for (int j = L; j >= 0; j--)
      memcpy(next[w[i] + j], o, sizeof(o)), j ? o[s[j] - 97] = j : 0;
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) scanf("%d", &id[i]);
  for (int i = m; i; i--) {
    memcpy(to[i], o, sizeof(o));
    for (int j = 0; j < 26; j++)
      if (next[w[id[i]]][j]) o[j] = i;
  }
  scanf("%s", s), n = strlen(s), f[0] = 1;
  for (int i = 0; i < n; i++, f[ans + 1] ? ans++ : 0)
    for (int j = ans; j >= 0; j--) {
      find(s[i] - 97, f[j], g[j], x, y);
      if (x && (!f[j + 1] || x * M + y < f[j + 1] * M + g[j + 1]))
        f[j + 1] = x, g[j + 1] = y;
    }
  printf("%d\n", ans);
  return 0;
}
