#include <bits/stdc++.h>
using namespace std;
long long fpm(long long b, long long e, long long m) {
  long long t = 1;
  for (; e; e >>= 1, b = b * b % m) e & 1 ? t = t * b % m : 0;
  return t;
}
template <class T>
inline bool chkmin(T &a, T b) {
  return a > b ? a = b, true : false;
}
template <class T>
inline bool chkmax(T &a, T b) {
  return a < b ? a = b, true : false;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class edge>
struct Graph {
  vector<vector<edge>> adj;
  Graph(int n) {
    adj.clear();
    adj.resize(n + 5);
  }
  Graph() { adj.clear(); }
  void resize(int n) { adj.resize(n + 5); }
  void add(int s, edge e) { adj[s].push_back(e); }
  void del(int s, edge e) { adj[s].erase(find(iter(adj[s]), e)); }
  int deg(int v) { return adj[v].size(); }
  vector<edge> &operator[](int t) { return adj[t]; }
};
const int maxn = 2200, maxm = 2200, maxt = 2200;
vector<vector<vector<int>>> nc;
vector<vector<int>> nb, lnk;
int n, m;
string S[maxn], T;
int blks[maxm];
pair<int, int> f[maxt][maxt];
void init_str(string &S, vector<vector<int>> &vec) {
  int len = (int)((S).size());
  vec.resize(len + 1);
  vec[len].resize(26);
  fill((vec[len]).begin(), (vec[len]).end(), 0x3F3F3F3F);
  for (int j = len - 1; j >= 0; --j) {
    vec[j] = vec[j + 1];
    vec[j][S[j] - 'a'] = j;
  }
}
void init() {
  nc.resize(n);
  for (int i = 0; i < n; ++i) init_str(S[i], nc[i]);
  init_str(T, lnk);
  nb.resize(m + 1);
  nb[m].resize(26);
  fill((nb[m]).begin(), (nb[m]).end(), 0x3F3F3F3F);
  for (int i = m - 1; i >= 0; --i) {
    nb[i] = nb[i + 1];
    for (int j = 0; j < 26; ++j)
      if (nc[blks[i]][0][j] != 0x3F3F3F3F) nb[i][j] = i;
  }
}
pair<int, int> find_next_char(pair<int, int> now, int c) {
  if (nc[blks[now.first]][now.second + 1][c] == 0x3F3F3F3F)
    now.first = nb[now.first + 1][c], now.second = -1;
  if (now.first == 0x3F3F3F3F) return make_pair(0x3F3F3F3F, 0);
  return make_pair(now.first, nc[blks[now.first]][now.second + 1][c]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> S[i];
  cin >> m;
  for (int i = 0; i < m; ++i) cin >> blks[i], --blks[i];
  cin >> T;
  init();
  memset(f, 0x3F, sizeof(f));
  f[0][0] = make_pair(0, -1);
  int ans = 0;
  for (int i = 0; i <= (int)((T).size()); ++i)
    for (int j = 0; j <= i + 1; ++j)
      if (f[i][j].first != 0x3F3F3F3F) {
        for (int c = 0; c < 26; ++c)
          if (lnk[i][c] != 0x3F3F3F3F)
            chkmin(f[lnk[i][c] + 1][j + 1], find_next_char(f[i][j], c));
        ans = max(ans, j);
      }
  cout << ans << endl;
  return 0;
}
