#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 1000;
const int MAXN = 2048;
string B[MAXN];
vector<int> nxt[26][MAXN];
int n, m;
int I[MAXN];
int next_word[26][MAXN];
pair<int, int> next_position(int ch, pair<int, int> pos, bool move) {
  if (move) {
    if (pos.second + 1 < ((int)(B[I[pos.first]]).size()))
      pos.second++;
    else if (pos.first + 1 < m)
      pos.first++, pos.second = 0;
    else
      return pair<int, int>(-1, -1);
  }
  if (nxt[ch][I[pos.first]][pos.second] == -1) {
    pos.first = next_word[ch][pos.first];
    if (pos.first == -1) return pair<int, int>(-1, -1);
    pos.second = nxt[ch][I[pos.first]][0];
    return pos;
  } else
    pos.second = nxt[ch][I[pos.first]][pos.second];
  return pos;
}
int main() {
  cin >> n;
  for (register int i = (0); i < (int)(n); ++i) {
    cin >> B[i];
    for (register int j = (0); j < (int)(26); ++j) {
      nxt[j][i].resize(((int)(B[i]).size()));
      fill((nxt[j][i]).begin(), (nxt[j][i]).end(), -1);
      for (int k = ((int)(B[i]).size()) - 1; k >= 0; k--) {
        if (k + 1 < ((int)(B[i]).size())) nxt[j][i][k] = nxt[j][i][k + 1];
        if (B[i][k] == j + 'a') nxt[j][i][k] = k;
      }
    }
  }
  cin >> m;
  for (register int i = (0); i < (int)(m); ++i) cin >> I[i], I[i]--;
  memset(next_word, -1, sizeof next_word);
  for (int i = m - 2; i >= 0; i--)
    for (register int j = (0); j < (int)(26); ++j) {
      next_word[j][i] = next_word[j][i + 1];
      if (nxt[j][I[i + 1]][0] != -1) next_word[j][i] = i + 1;
    }
  string s;
  cin >> s;
  vector<pair<int, int> > match(((int)(s).size()) + 1);
  match[0] = pair<int, int>(0, 0);
  for (register int i = (1); i < (int)(((int)(match).size())); ++i)
    match[i] = pair<int, int>(INF, INF);
  for (__typeof((s).begin()) it = (s).begin(); it != (s).end(); ++it) {
    int c = *it - 'a';
    for (int i = ((int)(match).size()) - 2; i >= 0; i--) {
      if (match[i].first == INF || match[i] == match[i + 1]) continue;
      pair<int, int> tmp = next_position(c, match[i], i != 0);
      if (tmp.first != -1) match[i + 1] = min(match[i + 1], tmp);
    }
  }
  int pos = ((int)(match).size()) - 1;
  while (match[pos].first == INF) pos--;
  cout << pos << "\n";
  return 0;
}
