#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 50;
pair<int, int> dp[maxn][maxn], arr[maxn][26];
int n, m, b[maxn], Length[maxn], Tlen;
vector<int> pos[maxn][26];
char T[maxn], temp[maxn * maxn];
void input(int idx) {
  scanf("%s", temp + 1);
  for (int i = 1; temp[i]; ++i) pos[idx][temp[i] - 'a'].push_back(i);
}
inline void updata(pair<int, int> &val, pair<int, int> s) {
  if (val.first == 0)
    val = s;
  else
    val = min(val, s);
}
int main(int argc, char *argv[]) {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) input(i);
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) scanf("%d", &b[i]);
  scanf("%s", T + 1);
  Tlen = strlen(T + 1);
  for (int i = m; i >= 1; --i)
    for (int j = 0; j < 26; ++j) {
      if (pos[b[i]][j].size())
        arr[i][j].first = i, arr[i][j].second = pos[b[i]][j][0];
      else
        arr[i][j] = arr[i + 1][j];
    }
  dp[0][0].first = 1, dp[0][0].second = 0;
  for (int i = 0; i < Tlen; ++i)
    for (int j = 0; j <= i; ++j)
      if (dp[i][j].first) {
        updata(dp[i + 1][j], dp[i][j]);
        int extra = T[i + 1] - 'a';
        pair<int, int> cur = dp[i][j];
        int fst = cur.first, scd = cur.second,
            nxtpos = upper_bound(pos[b[fst]][extra].begin(),
                                 pos[b[fst]][extra].end(), scd) -
                     pos[b[fst]][extra].begin();
        if (nxtpos != pos[b[fst]][extra].size())
          updata(dp[i + 1][j + 1], make_pair(fst, pos[b[fst]][extra][nxtpos]));
        else {
          pair<int, int> new_next = arr[fst + 1][extra];
          if (new_next.first) updata(dp[i + 1][j + 1], new_next);
        }
      }
  int ans = 0;
  for (int j = Tlen; j >= 0; --j)
    if (dp[Tlen][j].first) {
      ans = j;
      break;
    }
  printf("%d\n", ans);
  return 0;
}
