#include <iostream>
#include<ctime>
#include <fstream>
#include <string>
#include <vector>
#include <set>

using namespace std;

const long long MOD = 1000000007;
int main()
{
    ifstream in("scar.in");
    ofstream out("scar.out");
    int n;
    in >> n;
    vector<string> ss(n + 1);
    vector<int> slen(n + 1);
    ss[0] = "";
    slen[0] = 0;
    for (int i = 0; i < n; i++)
    {
        in >> ss[i + 1];
        slen[i + 1] = ss[i + 1].size();
    }
    
    vector<vector<int> > goodMasks(n + 1);
    goodMasks[0].push_back(0);
    for (int i = 0; i < n; i++)
    {
        set<string> used;
        for (int mask = 1; mask < (1 << (slen[i + 1])); mask++)
        {
            string s;
            for (int j = 0; j < slen[i + 1]; j++)
            {
                if (mask & (1 << j))
                {
                    s.push_back(ss[i + 1][j]);
                }
            }
            if (!used.count(s))
            {
                used.insert(s);
                goodMasks[i + 1].push_back(mask);
            }
        }
    }

    vector<vector<long long> > dp(n + 1);
    dp[0] = vector<long long>(1);
    dp[0][0] = 1;
    char c1[10];
    int c1s;
    char c2[10];
    int c2s;
    for (int i = 0; i < n; i++)
    {
        dp[i + 1] = vector<long long>(1 << slen[i + 1]);
        int masks1 = goodMasks[i].size();
        for (int mask1id = 0; mask1id < masks1; mask1id++)
        {
            int mask1 = goodMasks[i][mask1id];
            c1s = 0;
            for (int j = 0; j < slen[i]; j++)
            {
                if (mask1 & (1 << j))
                    c1[c1s++] = ss[i][j];
            }
            int masks2 = goodMasks[i + 1].size();
            for (int mask2id = 0; mask2id < masks2; mask2id++)
            {
                int mask2 = goodMasks[i + 1][mask2id];
                c2s = 0;
                for (int j = 0; j < slen[i + 1]; j++)
                {
                    if (mask2 & (1 << j))
                        c2[c2s++] = ss[i + 1][j];
                }
                bool allEq = true;
                bool less;
                int sz = min(c1s, c2s);
                for (int j = 0; j < sz; j++)
                {
                    if (c1[j] != c2[j])
                    {
                        allEq = false;
                        less = c1[j] < c2[j];
                        break;
                    }
                }
                if (allEq)
                {
                    less = c1s < c2s;
                }
                if (!less)
                    continue;
                dp[i + 1][mask2id] += dp[i][mask1id];
                if (dp[i + 1][mask2id] >= MOD)
                    dp[i + 1][mask2id] -= MOD;
            }
        }
    }
    long long ans = 0;
    for (int maskId = 0; maskId < goodMasks[n].size(); maskId++)
        ans += dp[n][maskId];
    ans %= MOD;
    out << ans << "\n";
}
