#include<iostream>
#include<cstring>
#include<string>
using namespace std;

int n, m, MOD = 1000000007;
string s[60];
int dp[51][51][21][27];

int solve(int l, int r, int p, int c){
	if(l == r || (l+1 == r && s[l].size() == p && !c)) return 1;
	if(s[l].size() == p){
		if(c) return 0;
		else if(l+1 == r) return 1;
		else if(l+1 < r && s[l+1].size() > p) return solve(l+1, r, p, c);
	}
	if(c >= 26) return 0;
	int &res = dp[l][r][p][c];
	if(res != -1) return res;
	res = 0;
	for(int i=l;i<=r;i++){
		res = (res + (long long)solve(l, i, p+1, 0) * solve(i, r, p, c+1)) % MOD;
		if(s[i].size() <= p || (s[i][p] != '?' && s[i][p] != 'a' + c)) break;
	}
	return res;
}

int main(){
	memset(dp, -1, sizeof(dp));
	cin >> n;
	for(int i=0;i<n;i++) cin >> s[i];
	cout << solve(0, n, 0, 0) << endl;
	return 0;
}