#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define len(v) ((ll)(v.size()))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inp(a) for(auto &x:a) cin>>x;
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vs vector<string>
#define vchar vector<char>
#define vvchar vector<vector<char>>
#define vpll vector<pair<ll,ll>>
#define mll map<ll,ll>
#define sll set<ll>
#define pn cout<<"NO\n"
#define py cout<<"YES\n"
#define pll pair<ll,ll>
const ll MAX_SIZE = 100005 ;
const ll ninf = ( - 1 ) * ( 1ll<< 60 ) ;
const ll inf = 1ll<< 60 ;
const ll mod = 1000000007 ;
ll t[ 4 * MAX_SIZE] ;
template < typename T>
void print( T t)
{
for ( const auto & e: t) cout << e<< " " ;
cout << "\n " ;
}
ll fastpow( ll a ,ll b) {
ll res= 1 ;
while ( b) {
if ( b& 1 ) res= ( res* a) % mod;
a= ( a* a) % mod;
b/ = 2 ;
}
return res;
}
struct hashFunction
{
size_t operator( ) ( const pair< ll ,
ll> & x) const
{
return x.first ^ x.second ;
}
} ;
ll p1= 31 ,p2= 67 ;
ll inv1[ MAX_SIZE] ;
ll pt1[ MAX_SIZE] ;
ll inv2[ MAX_SIZE] ;
ll pt2[ MAX_SIZE] ;
void solve( ll TC)
{
ll n;
cin >> n;
vs v( n) ;
inp( v) ;
string s;
cin >> s;
unordered_set< pll,hashFunction> m;
vll leng;
vll freq( 1e5 ,0 ) ;
for ( auto x: v) {
ll hash_value1= 0 ;
ll hash_value2= 0 ;
for ( ll i= 0 ; i< len( x) ; i++ ) {
hash_value1= ( hash_value1+ pt1[ i] * ( x[ i] - 'a' + 1 ) ) % mod;
hash_value2= ( hash_value2+ pt2[ i] * ( x[ i] - 'a' + 1 ) ) % mod;
}
m.insert ( { hash_value1,hash_value2} ) ;
if ( freq[ len( x) ] == 0 ) leng.push_back ( len( x) ) ;
freq[ len( x) ] = 1 ;
}
sort( all( leng) ) ;
vll hash1( len( s) + 1 ,0 ) ,hash2( len( s) + 1 ,0 ) ;
for ( ll i= 1 ; i<= len( s) ; i++ ) {
hash1[ i] = ( hash1[ i- 1 ] + pt1[ i- 1 ] * ( s[ i- 1 ] - 'a' + 1 ) ) % mod;
hash2[ i] = ( hash2[ i- 1 ] + pt2[ i- 1 ] * ( s[ i- 1 ] - 'a' + 1 ) ) % mod;
}
vll dp( len( s) + 1 ,0 ) ;
dp[ 0 ] = 1 ;
for ( ll i= 1 ; i<= len( s) ; i++ ) {
for ( auto l: leng) {
if ( l> i) break ;
ll k1= ( ( hash1[ i] - hash1[ i- l] + mod) * inv1[ i- l] ) % mod;
ll k2= ( ( hash2[ i] - hash2[ i- l] + mod) * inv2[ i- l] ) % mod;
if ( m.count ( { k1,k2} ) ) dp[ i] = ( dp[ i] + dp[ i- l] ) % mod;
}
}
cout << dp[ len( s) ] % mod<< endl;
}
int main( )
{
ios_base:: sync_with_stdio ( false ) ; cin .tie ( 0 ) ; cout .tie ( 0 ) ;
ll Tc= 1 ;
// cin>>Tc;
pt1[ 0 ] = 1 ,pt2[ 0 ] = 1 ;
inv1[ 0 ] = fastpow( 1 ,mod- 2 ) ;
inv2[ 0 ] = inv1[ 0 ] ;
ll k1= fastpow( p1,mod- 2 ) ;
ll k2= fastpow( p2,mod- 2 ) ;
for ( ll i= 1 ; i< MAX_SIZE; i++ ) {
pt1[ i] = ( pt1[ i- 1 ] * p1) % mod;
inv1[ i] = ( inv1[ i- 1 ] * k1) % mod;
pt2[ i] = ( pt2[ i- 1 ] * p2) % mod;
inv2[ i] = ( inv2[ i- 1 ] * k2) % mod;
}
for ( ll tc= 1 ; tc<= Tc; tc++ )
{
solve( tc) ;
}
return 0 ;
}
/*
1. Initialize all variables! Arrays etc.
2. Min of Max and Max of Min, such type of problems usually require Binary Search
3. Use to_string and stoi,atoi for conversions to suitable types.
4. For setting precision of n digits after decimal, use cout<<fixed;cout<<setprecision(n); before output, or at start of code if all outputs have same precision(include ios and iomanip header files.
5. Instead os using ceil(a/b), use (a+b-1)/b or (a-1)/b+1.
6. For char to int, subtract '0', for int to char add'0'
*/
CiNpbmNsdWRlIDxiaXRzL3N0ZGMrKy5oPgogCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKI2RlZmluZSBsbCBsb25nIGxvbmcgaW50CiNkZWZpbmUgbXAgbWFrZV9wYWlyCiNkZWZpbmUgZWIgZW1wbGFjZV9iYWNrCiNkZWZpbmUgcGIgcHVzaF9iYWNrCiNkZWZpbmUgbGVuKHYpICgobGwpKHYuc2l6ZSgpKSkKI2RlZmluZSBhbGwodikgdi5iZWdpbigpLHYuZW5kKCkKI2RlZmluZSByYWxsKHYpIHYucmJlZ2luKCksdi5yZW5kKCkKI2RlZmluZSBpbnAoYSkgZm9yKGF1dG8gJng6YSkgY2luPj54OwojZGVmaW5lIHZsbCB2ZWN0b3I8bGw+CiNkZWZpbmUgdnZsbCB2ZWN0b3I8dmVjdG9yPGxsPj4KI2RlZmluZSB2cyB2ZWN0b3I8c3RyaW5nPgojZGVmaW5lIHZjaGFyIHZlY3RvcjxjaGFyPgojZGVmaW5lIHZ2Y2hhciB2ZWN0b3I8dmVjdG9yPGNoYXI+PiAKI2RlZmluZSB2cGxsIHZlY3RvcjxwYWlyPGxsLGxsPj4gCiNkZWZpbmUgbWxsIG1hcDxsbCxsbD4gCiNkZWZpbmUgc2xsIHNldDxsbD4KI2RlZmluZSBwbiBjb3V0PDwiTk9cbiIKI2RlZmluZSBweSBjb3V0PDwiWUVTXG4iCiNkZWZpbmUgcGxsIHBhaXI8bGwsbGw+IApjb25zdCBsbCBNQVhfU0laRSA9IDEwMDAwNTsKY29uc3QgbGwgbmluZiA9ICgtMSkqKDFsbDw8NjApOwpjb25zdCBsbCBpbmYgPSAxbGw8PDYwOwpjb25zdCBsbCBtb2QgPSAxMDAwMDAwMDA3OwpsbCB0WzQqTUFYX1NJWkVdOwp0ZW1wbGF0ZTx0eXBlbmFtZSBUPgp2b2l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