#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXL = 1000010;
const int MAXN = 2020;
char mem_pool[MAXL * 3], *cur_pos = mem_pool;
inline char* alloc_mem(int size) {
  char* ret = cur_pos;
  cur_pos += size + 1;
  return ret;
}
char buf[MAXL], *strs[MAXN];
vector<int> vecs[MAXN][26];
int sum[MAXN];
int strid[MAXN];
int fir[MAXN][26];
int len[MAXN];
char T[MAXN];
int dp[MAXN][MAXN];
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%s", buf + 1);
    len[i] = strlen(buf + 1);
    strs[i] = alloc_mem(len[i] + 2);
    for (int j = 1; j <= len[i]; j++) strs[i][j] = buf[j];
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < 26; j++) vecs[i][j].resize(len[i] + 1, 0);
    for (int j = len[i]; j >= 1; j--) {
      if (j != len[i])
        for (int k = 0; k < 26; k++) vecs[i][k][j] = vecs[i][k][j + 1];
      vecs[i][strs[i][j] - 'a'][j] = j;
    }
  }
  int K;
  scanf("%d", &K);
  for (int i = 1; i <= K; i++) {
    scanf("%d", &strid[i]);
    sum[i] = sum[i - 1] + len[strid[i]];
  }
  for (int i = K; i >= 1; i--) {
    for (int j = 0; j < 26; j++) {
      if (vecs[strid[i]][j][1])
        fir[i][j] = i;
      else
        fir[i][j] = fir[i + 1][j];
    }
  }
  scanf("%s", T + 1);
  int M = strlen(T + 1);
  memset(dp, 0x3f, sizeof dp);
  dp[0][0] = 0;
  int ans = 0;
  for (int i = 1; i <= M; i++)
    for (int j = 0; j <= i; j++) {
      dp[i][j] = dp[i - 1][j];
      int pre = dp[i - 1][j - 1];
      if (pre <= sum[K]) {
        int pos = lower_bound(sum + 1, sum + K + 1, pre + 1) - sum;
        if (pos > K) continue;
        if (vecs[strid[pos]][T[i] - 'a'][pre + 1 - sum[pos - 1]])
          dp[i][j] =
              min(dp[i][j],
                  sum[pos - 1] +
                      vecs[strid[pos]][T[i] - 'a'][pre + 1 - sum[pos - 1]]);
        else {
          pos = fir[pos + 1][T[i] - 'a'];
          if (!pos) continue;
          dp[i][j] =
              min(dp[i][j], sum[pos - 1] + vecs[strid[pos]][T[i] - 'a'][1]);
        }
        if (dp[i][j] <= sum[K]) ans = max(ans, j);
      }
    }
  cout << ans << endl;
}
