#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T checkmin(T &a, T b) {
  return (a < b) ? a : a = b;
}
template <class T>
inline T checkmax(T &a, T b) {
  return (a > b) ? a : a = b;
}
template <class T>
T GCD(T a, T b) {
  if (a < 0) return GCD(-a, b);
  if (b < 0) return GCD(a, -b);
  return (a == 0) ? b : GCD(b % a, a);
}
template <class T>
T LCM(T a, T b) {
  if (a < 0) return LCM(-a, b);
  if (b < 0) return LCM(a, -b);
  return (a == 0 || b == 0) ? 0 : a / GCD(a, b) * b;
}
template <class T>
inline T sqr(T X) {
  return X * X;
}
namespace Poor {
const int MaxiN = 2005;
const int MaxiM = 2005;
const int MaxiS = 2005;
int N, M;
int Id[MaxiM];
pair<int, int> Opt[MaxiS][MaxiS];
string Base[MaxiN];
string St;
vector<int> List[MaxiN][26];
void Run() {
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> Base[i];
  cin >> M;
  for (int i = 0; i < M; ++i) {
    cin >> Id[i];
    --Id[i];
  }
  cin >> St;
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < (int)Base[i].size(); ++j)
      List[i][Base[i][j] - 'a'].push_back(j);
  int Len = St.size();
  for (int i = 0; i < Len + 1; ++i)
    for (int j = 0; j < Len + 1; ++j) Opt[i][j] = make_pair(M, 0);
  Opt[0][0] = make_pair(0, 0);
  for (int i = 1; i <= Len; ++i) {
    int t = St[i - 1] - 'a';
    Opt[i][0] = make_pair(0, 0);
    for (int j = 1; j <= i; ++j) {
      Opt[i][j] = Opt[i - 1][j];
      pair<int, int> Tmp = Opt[i - 1][j - 1];
      while (Tmp < Opt[i][j]) {
        vector<int>::iterator it =
            lower_bound(List[Id[Tmp.first]][t].begin(),
                        List[Id[Tmp.first]][t].end(), Tmp.second);
        if (it != List[Id[Tmp.first]][t].end()) {
          Tmp.second = *it + 1;
          break;
        }
        ++Tmp.first;
        Tmp.second = 0;
      }
      checkmin(Opt[i][j], Tmp);
    }
  }
  for (int j = Len; j >= 0; --j)
    if (Opt[Len][j] < make_pair(M, 0)) {
      cout << j << endl;
      break;
    }
}
}  // namespace Poor
int main() {
  ios::sync_with_stdio(false);
  Poor::Run();
  return 0;
}
