#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000;
const int MAX = 2010;
const int inf = 1000 * 1000 * 1000;
const int p1 = 104393321, p2 = 104393329;
int n, m;
string s;
vector<int> LEFT[MAX][26];
int base[MAX][26];
int has[MAX][26], h[MAX], t[26];
pair<int, int> d[MAX][MAX];
string b[MAX];
pair<int, int> find(pair<int, int> x, int c) {
  int p, q;
  if (x.first == m) return pair<int, int>(-1, -1);
  p = LEFT[h[x.first]][c][x.second];
  if (p == -1) {
    p = base[x.first][c];
    if (p == -1) return pair<int, int>(-1, -1);
    q = LEFT[h[p]][c][0];
    if (q == b[h[p]].size() - 1) q = -1, p++;
    return pair<int, int>(p, q + 1);
  }
  if (p == b[h[x.first]].size() - 1) p = -1, x.first++;
  return pair<int, int>(x.first, p + 1);
}
pair<int, int> MIN(pair<int, int> x, pair<int, int> y) {
  if (x.first == -1) return y;
  if (y.first == -1) return x;
  if (x.first == y.first) return (x.second < y.second ? x : y);
  return (x.first < y.first ? x : y);
}
int main(int argc, char **argv) {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = (0); i < int(n); ++i) cin >> b[i];
  cin >> m;
  for (int i = (0); i < int(m); ++i) {
    cin >> h[i];
    h[i]--;
  }
  cin >> s;
  for (int i = (0); i < int(n); ++i) {
    memset(t, -1, sizeof t);
    for (int c = (0); c < int(26); ++c) LEFT[i][c].resize(b[i].size());
    for (int j = (b[i].size()) - 1; j >= int(0); --j) {
      t[b[i][j] - 'a'] = j;
      has[i][b[i][j] - 'a'] = true;
      for (int c = (0); c < int(26); ++c) {
        LEFT[i][c][j] = t[c];
      }
    }
  }
  memset(t, -1, sizeof t);
  for (int i = (m)-1; i >= int(0); --i) {
    for (int c = (0); c < int(26); ++c) {
      base[i][c] = t[c];
      if (has[h[i]][c]) t[c] = i;
    }
  }
  int ans = 0;
  for (int i = (0); i < int(s.size() + 1); ++i)
    for (int j = (0); j < int(s.size() + 1); ++j)
      d[i][j] = pair<int, int>(-1, -1);
  for (int j = (0); j < int(s.size()); ++j) d[j][0] = pair<int, int>(0, 0);
  d[0][1] = find(pair<int, int>(0, 0), s[0] - 'a');
  if (d[0][1].first != -1) ans = 1;
  for (int i = (1); i < int(s.size()); ++i) {
    for (int j = (1); j < int(i + 2); ++j) {
      d[i][j] = pair<int, int>(-1, -1);
      if (d[i - 1][j - 1].first != -1)
        d[i][j] = find(d[i - 1][j - 1], s[i] - 'a');
      d[i][j] = MIN(d[i][j], d[i - 1][j]);
      if (d[i][j].first != -1) ans = max(ans, j);
    }
  }
  cout << ans << endl;
  return 0;
}
