#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int N;
string s[55];
ll dp[55][55][23][30];
const char e='a'-1;

ll dfs(int l,int r,int i,int c){
  if(l>=r)return 1;
  if(i==20)return l+1==r?1:0;
  if(dp[l][r][i][c]!=-1)return dp[l][r][i][c];

  ll res=0;
  if(c==26){
    bool ok=true;
    repl(j,l,r){
      if(s[j][i]!='?'&&s[j][i]!=e+c)ok=false;
    }
    if(ok)res=dfs(l,r,i+1,0);
  }else if(c!=0){
    res=dfs(l,r,i,c+1);
    repl(j,l,r){
      if(s[j][i]!='?'&&s[j][i]!=e+c)break;
      ll vl=dfs(l,j+1,i+1,0);
      ll vr=dfs(j+1,r,i,c+1);
      (res+=vl*vr%mod)%=mod;
    }
  }else{
    res=dfs(l,r,i,c+1);
    repl(j,l,r){
      if(s[j][i]!=e+c)break;
      ll vl=dfs(l,j+1,i+1,0);
      ll vr=dfs(j+1,r,i,c+1);
      (res+=vl*vr%mod)%=mod;
    }
  }
  return dp[l][r][i][c]=res;
}

int main(){
  cin>>N;
  rep(i,N){
    cin>>s[i];
    while(s[i].size()<21)s[i]+=e;
  }
  memset(dp,-1,sizeof(dp));
  cout<<dfs(0,N,0,0)<<endl;
  return 0;
}

