#include <bits/stdc++.h>
using namespace std;
string s[2010];
int a[2010];
string t;
vector<int> nextpos[2010][26];
int nexts[2010][26];
int First[2010][26];
int freq[2010][26];
int Next[26];
pair<int, int> dp[2010][2010];
pair<int, int> getnext(pair<int, int> cur, int c) {
  if (cur.first == 1000000000) return make_pair(1000000000, 1000000000);
  if (nextpos[a[cur.first]][c][cur.second] < 1000000000)
    return make_pair(cur.first, nextpos[a[cur.first]][c][cur.second]);
  if (nexts[cur.first][c] < 1000000000)
    return make_pair(nexts[cur.first][c], First[a[nexts[cur.first][c]]][c]);
  return make_pair(1000000000, 1000000000);
}
pair<int, int> getfirst(int c) {
  if (First[a[0]][c] < 1000000000) return make_pair(0, First[a[0]][c]);
  if (nexts[0][c] < 1000000000)
    return make_pair(nexts[0][c], First[a[nexts[0][c]]][c]);
  return make_pair(1000000000, 1000000000);
}
int main() {
  int n, m, i, j, k;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    cin >> s[i];
    for (j = 0; j < 26; ++j) {
      freq[i][j] = 0;
      First[i][j] = 1000000000;
      nextpos[i][j].resize((int)s[i].length());
      for (k = 0; k < (int)s[i].length(); ++k) nextpos[i][j][k] = 1000000000;
      Next[j] = 1000000000;
    }
    for (j = (int)s[i].length() - 1; j >= 0; --j) {
      for (k = 0; k < 26; ++k) nextpos[i][k][j] = Next[k];
      freq[i][s[i][j] - 'a']++;
      First[i][s[i][j] - 'a'] = j;
      Next[s[i][j] - 'a'] = j;
    }
  }
  for (i = 0; i < 26; ++i) Next[i] = 1000000000;
  scanf("%d", &m);
  for (i = 0; i < m; ++i) {
    scanf("%d", &a[i]);
    a[i]--;
  }
  for (i = m - 1; i >= 0; --i) {
    for (j = 0; j < 26; ++j) nexts[i][j] = Next[j];
    for (j = 0; j < 26; ++j)
      if (freq[a[i]][j]) Next[j] = i;
  }
  cin >> t;
  for (i = 0; i < (int)t.length(); ++i)
    for (j = 0; j <= (int)t.length(); ++j)
      dp[i][j] = make_pair(1000000000, 1000000000);
  dp[0][1] = getfirst(t[0] - 'a');
  for (i = 1; i < (int)t.length(); ++i)
    dp[i][1] = min(dp[i - 1][1], getfirst(t[i] - 'a'));
  for (j = 2; j <= (int)t.length(); ++j) {
    for (i = 1; i < (int)t.length(); ++i)
      dp[i][j] = min(dp[i - 1][j], getnext(dp[i - 1][j - 1], t[i] - 'a'));
  }
  for (j = (int)t.length(); j >= 1; --j)
    if (dp[(int)t.length() - 1][j].first < 1000000000) break;
  printf("%d\n", j);
}
