#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> vs[2002];
int len[2002];
vector<int> siguiente[2002][26];
int hay[2002][26];
int siguientehay[2002][26];
int m;
int indice[2002];
vector<int> s;
int npos;
pair<int, int> pos[2002];
pair<int, int> obtensiguiente(pair<int, int> p, int c) {
  int i = p.first;
  int j = p.second;
  int indi = indice[i];
  if (i != -1 and siguiente[indi][c][j + 1] < len[indi])
    return pair<int, int>(i, siguiente[indi][c][j + 1]);
  if (siguientehay[i + 1][c] < m)
    return pair<int, int>(siguientehay[i + 1][c],
                          siguiente[indice[siguientehay[i + 1][c]]][c][0]);
  return pair<int, int>(m, 0);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    vs[i] = vector<int>(int(s.size()));
    len[i] = int(s.size());
    for (int j = 0; j < int(s.size()); j++) vs[i][j] = s[j] - 'a';
    for (int c = 0; c < 26; c++) {
      siguiente[i][c] = vector<int>(int(s.size()) + 1, int(s.size()));
      for (int j = int(s.size()) - 1; j >= 0; j--) {
        siguiente[i][c][j] = siguiente[i][c][j + 1];
        if (vs[i][j] == c) {
          siguiente[i][c][j] = j;
          hay[i][c] = 1;
        }
      }
    }
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> indice[i];
    indice[i]--;
  }
  for (int c = 0; c < 26; c++) siguientehay[m][c] = m;
  for (int i = m - 1; i >= 0; i--) {
    for (int c = 0; c < 26; c++) {
      siguientehay[i][c] = siguientehay[i + 1][c];
      if (hay[indice[i]][c]) siguientehay[i][c] = i;
    }
  }
  {
    string input;
    cin >> input;
    s = vector<int>(int(input.size()));
    for (int i = 0; i < int(input.size()); i++) s[i] = input[i] - 'a';
  }
  pos[0] = pair<int, int>(-1, 0);
  npos = 1;
  for (int i = 0; i < int(s.size()); i++) {
    int c = s[i];
    for (int ipos = npos - 1; ipos >= 0; ipos--) {
      pair<int, int> nextp = obtensiguiente(pos[ipos], c);
      if (nextp.first < m and (ipos + 1 == npos or nextp < pos[ipos + 1])) {
        pos[ipos + 1] = nextp;
        if (ipos + 1 == npos) npos++;
      }
    }
  }
  cout << npos - 1 << endl;
}
