#include<iostream>
#include<cstdio>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<vector> 
#include<cstring>
#include<string>
#include<map>
#define mp make_pair
#define scn second
#define frs first
#define pb push_back
#define NAME "scar"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pi;

map<string, int> was;
vector<int> arr_now, arr_back;
int NMB, n;
char s[111][100];
int len[1000];
int nn[111][50000];
int dp[3][50000];
const int mod = 1000000007;
string get_string(int mask) {
	int k = NMB;
	string ans = "";
	for (int i = 0; i < len[k]; ++i)
		if ((1 << i) & mask)
			ans += s[k][i];
	return ans;
}

bool cmp(int a, int b) {
	int k = NMB;
	int y = 0, p = 0;
	while (y < len[k] && !((1 << y) & a))
		++y;
	while (p < len[k] && !((1 << p) & b))
		++p;
	for (;y < len[k] && p < len[k];) {
		if (s[k][y] != s[k][p])
			return s[k][y] < s[k][p];
		++y, ++p;
		while (y < len[k] && !((1 << y) & a))
			++y;
		while (p < len[k] && !((1 << p) & b))
			++p;		
	}	
	int cnt1 = 0, cnt2 = 0;
	for (int i = 0; i < len[k]; ++i)
		cnt1 += !!((1 << i) & a), cnt2 += !!((1 << i) & b);
	return cnt1 < cnt2;	
}


void my_sort(vector<int> &_arr, int k) {
	NMB = k;
	sort(_arr.begin(), _arr.end(), cmp);
}
bool aB(int m1, int k1, int m2, int k2) {
	string ansa = "", ansb = "";
	for (int i = 0; i < len[k1]; ++i)
		if ((1 << i) & m1)
			ansa += s[k1][i];
	for (int i = 0; i < len[k2]; ++i)
		if ((1 << i) & m2)
			ansb += s[k2][i];
	return ansa < ansb;	
}
double start;
int main(){
	start = clock();
//	srand(time(NULL));
	freopen(NAME ".in", "r", stdin); 
	freopen(NAME ".out", "w", stdout); 
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)	
		scanf("%s", s[i]), len[i] = strlen(s[i]);;
	for (int i = 0; i < n; ++i) {
		NMB = i;
		was.clear();
		for (int mask = 1; mask < 1 << len[i]; ++mask)
			if (was[get_string(mask)])
				nn[i][mask] = 1;				
			else
				was[get_string(mask)] = 1;
	}
	for (int i = 1; i < 1 << len[0]; ++i)
    	dp[0][i] = !nn[0][i];    
    for (int mask = 1; mask < 1 << len[0]; ++mask)
    		arr_back.pb(mask);    	
    my_sort(arr_back, 0);
    for (int i = 1; i < n; ++i) {		
		for (int mask = 1; mask < 1 << len[i]; ++mask) 
    	//    if (!nn[i][mask])
    			arr_now.pb(mask);
		my_sort(arr_now, i);
		int y = 0;
		NMB = i;
		while (y < arr_back.size() && !aB(arr_back[0], i - 1, arr_now[y], i))
			++y;				
		ll ans = 0;
		for (int j = 0; j  < arr_now.size(); ++j) 
			dp[i & 1][arr_now[j]] = 0;     
			
		for (int j = y, y = 0; j < arr_now.size(); ++j) {
			while (y < arr_back.size() && aB(arr_back[y], i - 1, arr_now[j], i))
				ans += dp[(i - 1) & 1][arr_back[y]], ans %= mod, ++y;
			if (!nn[i][arr_now[j]])
				dp[(i) & 1][arr_now[j]] += ans, dp[(i) & 1][arr_now[j]] %= mod;
		}
		arr_back.clear();			
		arr_back = arr_now;
		arr_now.clear();
	}
    ll ans = 0;
    for (int i = 1; i < 1 << len[n - 1]; ++i)
    	ans += dp[(n - 1) & 1][i], ans %= mod;
    printf("%I64d\n", ans);	
	//cerr << (clock() - start) / CLOCKS_PER_SEC << "\n";
	return 0;
}




