#include<stdio.h>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <functional>
#include <stdio.h>
#include <array>
#include <algorithm>
#include <string>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <queue>
#include<iomanip>
#include<bitset>
#include<stack>
#include<set>
#include<limits>
#include <complex>
#include<cstdlib>
using namespace std;




const int mod = 1000000007;
struct Mod {
public:
	int num;
	Mod() : num(0) {}
	Mod(long long int n) : num((n % mod + mod) % mod) { ; }
	operator int() { return num; }

private:

};

Mod operator+(const Mod a, const Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator+(const long long int a, const Mod b) { return Mod(a) + b; }
Mod operator++(Mod &a) { return a + Mod(1); }
Mod operator-(const Mod a, const Mod b) { return Mod((mod + a.num - b.num) % mod); }
Mod operator-(const long long int a, const Mod b) { return Mod(a) - b; }
Mod operator--(Mod &a) { return a - Mod(1); }
Mod operator*(const Mod a, const Mod b) { return Mod(((long long)a.num * b.num) % mod); }
Mod operator*(const long long int a, const Mod b) { return Mod(a)*b; }
Mod operator+=(Mod &a, const Mod b) { return a = a + b; }
Mod operator+=(long long int &a, const Mod b) { return a = a + b; }
Mod operator-=(Mod &a, const Mod b) { return a = a - b; }
Mod operator-=(long long int &a, const Mod b) { return a = a - b; }
Mod operator*=(Mod &a, const Mod b) { return a = a * b; }
Mod operator*=(long long int &a, const Mod b) { return a = a * b; }
Mod operator^(const Mod a, const int n) {
	if (n == 0) return Mod(1);
	Mod res = (a * a) ^ (n / 2);
	if (n % 2) res = res * a;
	return res;
}
Mod inv(const Mod a) { return a ^ (mod - 2); }
Mod operator/(const Mod a, const Mod b) {
	assert(b.num != 0);
	return a * inv(b);
}
Mod operator/(const long long int a, const Mod b) {
	assert(b.num != 0);
	return Mod(a) * inv(b);
}
Mod operator/=(Mod &a, const Mod b) {
	assert(b.num != 0);
	return a = a * inv(b);
}

#define MAX_MOD_N 1024000

Mod fact[MAX_MOD_N], factinv[MAX_MOD_N];
void init() {
	fact[0] = Mod(1); factinv[0] = 1;
	for (int i = 0; i < MAX_MOD_N - 1; ++i) {
		fact[i + 1] = fact[i] * Mod(i + 1);
		factinv[i + 1] = factinv[i] / Mod(i + 1);
	}
}
Mod comb(const int a, const int b) {
	return fact[a] * factinv[b] * factinv[a - b];
}


Mod memo[51][51][51][51];

bool decide[51][51][51][51];

vector<string>sts;
Mod getans(const int l, const int r,const int place, const int num) {
	if (decide[l][r][place][num]) {
		return memo[l][r][place][num];
	}
	else {
		decide[l][r][place][num] = true;

		if (l == r) {
			return memo[l][r][place][num]=Mod(1);
		}

		else if (l + 1 == r) {
			Mod ans(1);
			if (sts[l][place] == '?') {
				ans *= min(26,26 - num+1);
			}
			else if (sts[l][place] < 'a' + num-1) {
				return memo[l][r][place][num] = 0;
			}
			for (int n = place+1; n < sts[0].size(); ++n) {
				if (sts[l][n] == '?') {
					ans *= 26;
				}
			}
			return memo[l][r][place][num] = ans;
		}
		else {
			for (int n = l; n < r; ++n) {
				if (sts[n][place] >= 'a' + num - 1 || sts[n][place] == '?') {

				}
				else {
					return memo[l][r][place][num] = Mod(0);
				}
			}
			Mod ans(0);
			if (place == sts[0].size() - 1 && num == 26) {
				return memo[l][r][place][num] = Mod(0);
			}else if (place == sts[0].size() - 1) {
				if (sts[l][place] == 'a' + num - 1 || num != 0 && sts[l][place] == '?') {
					ans += getans(l + 1, r, place, num + 1);
				}
				ans += getans(l, r, place, num + 1);
				return memo[l][r][place][num] = ans;
			}
			else if (num == 26) {
				return memo[l][r][place][num] = getans(l, r, place + 1, 0);
			}
			else {
				for (int k = l; k <= r; ++k) {
					bool ok = true;
					for (int a = l; a < k; ++a) {
						if (sts[a][place] == 'a' + num - 1 || (num!=0&&sts[a][place] == '?')) {

						}
						else {
							ok = false;
							break;
						}
					}
					if (ok) {

						ans += getans(l, k, place + 1, 0)*getans(k, r, place, num + 1);

					}
				}
				return memo[l][r][place][num] = ans;
			}
		}
	}
}
int main() {
	memset(decide, false, sizeof(decide)); 
	int n; cin >> n;
	sts.resize(n); 
	for (int i = 0; i < n; ++i) {
		string st; cin >> st;
		int si = st.size();
		for (int j = 0; j < 20 - si; ++j) {
			st.push_back('a' - 1);
		}
		sts[i] = st;
	}
	Mod ans(getans(0, n, 0, 0));
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 44308