#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int dp[3001][3002];
long long solve(int i,string &target,int prev,unordered_map<char,vector<int>>&mp){
if(i == target.size()) return 1;
if(dp[prev+1][i] != -1) return dp[prev+1][i];
long long ans = 0;
auto &vec = mp[target[i]];
for(auto idx : vec){
if(idx > prev)
ans = (ans + solve(i+1,target,idx,mp)) % mod;
}
return dp[prev+1][i] = ans;
}
int main() {
int n; cin>>n;
vector<string> arr(n);
for(auto &it : arr) cin>>it;
string target; cin>>target;
unordered_map<char,vector<int>> mp;
for(auto &str : arr){
for(int i=0;i<str.size();i++){
mp[str[i]].push_back(i);
}
}
memset(dp,-1,sizeof dp);
cout<<solve(0,target,-1,mp)<<endl;
}