#include <bits/stdc++.h>
using namespace std;
void _print() { cerr << "]" << endl; }
template<typename T, typename... V>
void _print(T t, V... v) { cerr << t; if (sizeof...(v)) cerr << ", "; _print(v...); }
//#define LOCAL
#ifdef LOCAL
#define dbg(x...) cerr << "[" << #x << "]: ["; _print(x)
#else
#define dbg(x...)
#define endl '\n'
#endif
#define pb push_back
#define ff first
#define ss second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forne(i, n) for (int i = 0; i <= n; ++i)
#define rforn(i, n) for (int i = n-1; i >= 0; --i)
#define forab(i, a, b) for (int i = a; i < b; ++i)
#define forabe(i, a, b) for (int i = a; i <= b; ++i)
#define form(i, n, m, x) for (int i = n; i < m; i += x)
#define rform(i, n, m, x) for (int i = n; i >= m; i -= x)
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
const ll mod = 1000000007;
const ll p = 257;
ll power[100002];
void pre(){
power[0] = 1;
forab(i, 1, 100002){
power[i] = (power[i-1] * p) % mod;
}
}
ll get_hash(string &s){
ll h = 0;
forn(i, sz(s)){
h = (h + (s[i] * power[i])) % mod;
}
return h;
}
vector<string> words;
vector<ll> hwords;
string s;
struct node{
int len;
ll h;
node(){}
node(int _l, ll _h){
len = _l; h = _h;
}
};
struct STree {
int n; vector<node> st;
node neutro = node(0, 0);
STree(){}
void build(string &a) {
n = sz(a);
st.resize(n * 4);
build(1, 0, n - 1, a);
}
node oper(node a, node b) {
node n = node(a.len + b.len, (a.h+b.h*power[a.len]) % mod);
return n;
}
void build(int v, int tl, int tr, string &a) {
if(tl == tr) {
st[v] = node(1, a[tl]);
return;
}
int tm = (tr + tl) / 2;
build(v * 2, tl, tm, a);
build(v * 2 + 1, tm + 1, tr, a);
st[v] = oper(st[v * 2], st[v * 2 + 1]);
}
node query(int v, int tl, int tr, int l, int r) {
if(tl > r || tr < l) return neutro;
if(l <= tl && tr <= r) return st[v];
int tm = (tl + tr) / 2;
return oper(query(v * 2, tl, tm, l, r), query(v * 2 + 1, tm + 1, tr, l, r));
}
ll query(int l, int r) { return query(1, 0, n - 1, l, r).h; }
};
int n;
int memo[100002];
STree st;
int dp(int i){
if(i >= sz(s)) return 1;
if(memo[i] != -1) return memo[i];
//dbg(i);
int ans = 0;
forn(k, n){
//ll h = st.query(i, i+sz(words[k])-1);
//dbg("#", hwords[k], h, i, i+sz(words[k])-1);
if(hwords[k] == st.query(i, i+sz(words[k])-1)){
ans = (ans + dp(i + sz(words[k]))) % mod;
}
}
return memo[i] = ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
pre();
while(cin >> n){
words.clear();
hwords.clear();
string x;
forn(i, n){
cin >> x;
words.pb(x);
hwords.pb(get_hash(x));
}
cin >> s;
st.build(s);
memset(memo, -1, sizeof memo);
int res = dp(0);
cout << res << '\n';
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp2b2lkIF9wcmludCgpIHsgY2VyciA8PCAiXSIgPDwgZW5kbDsgfQp0ZW1wbGF0ZTx0eXBlbmFtZSBULCB0eXBlbmFtZS4uLiBWPgp2b2lkIF9wcmludChUIHQsIFYuLi4gdikgeyBjZXJyIDw8IHQ7IGlmIChzaXplb2YuLi4odikpIGNlcnIgPDwgIiwgIjsgX3ByaW50KHYuLi4pOyB9CgovLyNkZWZpbmUgTE9DQUwKI2lmZGVmIExPQ0FMCiAgI2RlZmluZSBkYmcoeC4uLikgY2VyciA8PCAiWyIgPDwgI3ggPDwgIl06IFsiOyBfcHJpbnQoeCkKI2Vsc2UKICAjZGVmaW5lIGRiZyh4Li4uKQogICNkZWZpbmUgZW5kbCAnXG4nCiNlbmRpZgoKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBmZiBmaXJzdAojZGVmaW5lIHNzIHNlY29uZAojZGVmaW5lIHN6KHgpIGludCh4LnNpemUoKSkKI2RlZmluZSBhbGwoeCkgeC5iZWd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pbnQgbGVuOwogICAgbGwgaDsKCiAgICBub2RlKCl7fQogICAgbm9kZShpbnQgX2wsIGxsIF9oKXsKICAgICAgICBsZW4gPSBfbDsgIGggPSBfaDsKICAgIH0KfTsKCnN0cnVjdCBTVHJlZSB7CiAgICBpbnQgbjsgdmVjdG9yPG5vZGU+IHN0OwogICAgbm9kZSBuZXV0cm8gPSBub2RlKDAsIDApOwoKICAgIFNUcmVlKCl7fQoKICAgIHZvaWQgYnVpbGQoc3RyaW5nICZhKSB7CiAgICAgICAgbiA9IHN6KGEpOwogICAgICAgIHN0LnJlc2l6ZShuICogNCk7CiAgICAgICAgYnVpbGQoMSwgMCwgbiAtIDEsIGEpOwogICAgfQoKICAgIG5vZGUgb3Blcihub2RlIGEsIG5vZGUgYikgewogICAgICAgIG5vZGUgbiA9IG5vZGUoYS5sZW4gKyBiLmxlbiwgKGEuaCtiLmgqcG93ZXJbYS5sZW5dKSAlIG1vZCk7CiAgICAgICAgcmV0dXJuIG47CiAgICB9CgogICAgdm9pZCBidWlsZChpbnQgdiwgaW50IHRsLCBpbnQgdHIsIHN0cmluZyAmYSkgewogICAgICAgIGlmKHRsID09IHRyKSB7CiAgICAgICAgICAgIHN0W3ZdID0gbm9kZSgxLCBhW3RsXSk7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgaW50IHRtID0gKHRyICsgdGwpIC8gMjsKICAgICAgICBidWlsZCh2ICogMiwgdGwsIHRtLCBhKTsKICAgICAgICBidWlsZCh2ICogMiArIDEsIHRtICsgMSwgdHIsIGEpOwogICAgICAgIHN0W3ZdID0gb3BlcihzdFt2ICogMl0sIHN0W3YgKiAyICsgMV0pOwogICAgfQoKICAgIG5vZGUgcXVlcnkoaW50IHYsIGludCB0bCwgaW50IHRyLCBpbnQgbCwgaW50IHIpIHsKICAgICAgICBpZih0bCA+IHIgfHwgdHIgPCBsKSByZXR1cm4gbmV1dHJvOwogICAgICAgIGlmKGwgPD0gdGwgJiYgdHIgPD0gcikgcmV0dXJuIHN0W3ZdOwogICAgICAgIGludCB0bSA9ICh0bCArIHRyKSAvIDI7CiAgICAgICAgcmV0dXJuIG9wZXIocXVlcnkodiAqIDIsIHRsLCB0bSwgbCwgciksIHF1ZXJ5KHYgKiAyICsgMSwgdG0gKyAxLCB0ciwgbCwgcikpOwogICAgfQoKICAgIGxsIHF1ZXJ5KGludCBsLCBpbnQgcikgeyByZXR1cm4gcXVlcnkoMSwgMCwgbiAtIDEsIGwsIHIpLmg7IH0KfTsKCmludCBuOwppbnQgbWVtb1sxMDAwMDJdOwpTVHJlZSBzdDsKCmludCBkcChpbnQgaSl7CiAgICBpZihpID49IHN6KHMpKSByZXR1cm4gMTsKICAgIGlmKG1lbW9baV0gIT0gLTEpIHJldHVybiBtZW1vW2ldOwogICAgLy9kYmcoaSk7CgogICAgaW50IGFucyA9IDA7CiAgICBmb3JuKGssIG4pewogICAgICAgIC8vbGwgaCA9IHN0LnF1ZXJ5KGksIGkrc3ood29yZHNba10pLTEpOwogICAgICAgIC8vZGJnKCIjIiwgaHdvcmRzW2tdLCBoLCBpLCBpK3N6KHdvcmRzW2tdKS0xKTsKICAgICAgICBpZihod29yZHNba10gPT0gc3QucXVlcnkoaSwgaStzeih3b3Jkc1trXSktMSkpewogICAgICAgICAgICBhbnMgPSAoYW5zICsgZHAoaSArIHN6KHdvcmRzW2tdKSkpICUgbW9kOwogICAgICAgIH0KICAgIH0KICAgIHJldHVybiBtZW1vW2ldID0gYW5zOwp9CgppbnQgbWFpbigpIHsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwogICAgY2luLnRpZSgwKTsKICAgIHByZSgpOwoKICAgIHdoaWxlKGNpbiA+PiBuKXsKICAgICAgICB3b3Jkcy5jbGVhcigpOwogICAgICAgIGh3b3Jkcy5jbGVhcigpOwoKICAgICAgICBzdHJpbmcgeDsKICAgICAgICBmb3JuKGksIG4pewogICAgICAgICAgICBjaW4gPj4geDsKICAgICAgICAgICAgd29yZHMucGIoeCk7CiAgICAgICAgICAgIGh3b3Jkcy5wYihnZXRfaGFzaCh4KSk7CiAgICAgICAgfQoKICAgICAgICBjaW4gPj4gczsKICAgICAgICBzdC5idWlsZChzKTsKCiAgICAgICAgbWVtc2V0KG1lbW8sIC0xLCBzaXplb2YgbWVtbyk7CiAgICAgICAgaW50IHJlcyA9IGRwKDApOwogICAgICAgIGNvdXQgPDwgcmVzIDw8ICdcbic7CiAgICB9CgogICAgcmV0dXJuIDA7Cn0KCgo=