#include <bits/stdc++.h>
using namespace std;
inline void upd(pair<int, int> &x, pair<int, int> y) {
  if (x > y) x = y;
}
pair<int, int> dp[2005][2005];
vector<vector<int> > nxt[2005];
bool app[2005][35];
int nxt_app[2005][35], len[2005], arr[2005];
char str[1000005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", str);
    len[i] = strlen(str);
    nxt[i].resize(len[i] + 1);
    for (int j = 0; j <= len[i]; j++) nxt[i][j].resize(26);
    for (int j = 0; j < 26; j++) nxt[i][len[i]][j] = len[i];
    for (int j = len[i] - 1; j >= 0; j--) {
      for (int k = 0; k < 26; k++) nxt[i][j][k] = nxt[i][j + 1][k];
      nxt[i][j][str[j] - 'a'] = j;
      app[i][str[j] - 'a'] = true;
    }
  }
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) scanf("%d", arr + i);
  for (int i = 0; i < 26; i++) nxt_app[m][i] = m;
  for (int i = m - 1; i >= 0; i--) {
    arr[i]--;
    for (int j = 0; j < 26; j++) {
      nxt_app[i][j] = nxt_app[i + 1][j];
      if (app[arr[i]][j]) nxt_app[i][j] = i;
    }
  }
  scanf("%s", str);
  n = strlen(str);
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= i; j++) dp[i][j] = make_pair(m, 0);
  }
  dp[0][0] = make_pair(0, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i; j++) {
      upd(dp[i + 1][j], dp[i][j]);
      if (dp[i][j].first >= m) continue;
      if (nxt[arr[dp[i][j].first]][dp[i][j].second][str[i] - 'a'] <
          len[arr[dp[i][j].first]])
        upd(dp[i + 1][j + 1],
            make_pair(
                dp[i][j].first,
                nxt[arr[dp[i][j].first]][dp[i][j].second][str[i] - 'a'] + 1));
      else if (nxt_app[dp[i][j].first + 1][str[i] - 'a'] < m) {
        int x = nxt_app[dp[i][j].first + 1][str[i] - 'a'];
        upd(dp[i + 1][j + 1], make_pair(x, nxt[arr[x]][0][str[i] - 'a'] + 1));
      }
    }
  }
  for (int i = n; i >= 0; i--) {
    if (dp[n][i].first < m) {
      printf("%d\n", i);
      return 0;
    }
  }
  return 0;
}
