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

typedef long long ll;
#define MOD (1000000007LL)

int N;
string S[51];

ll dp[52][52][22][30];

ll solve(int up,int down,int id,int c){

  ll &ret = dp[up][down][id][c];
  if( ret != -1 ) return ret;
  if( up > down ) return ret = 1LL;
  if( c > 26 ) return ret = 0LL;
  if( id == (int)S[up].size() ) {
    if( up == down) return ret = 1LL;
    return ret = 0LL;
  }

  char ch = c + 'a' - 1;
  ret = solve(up,down,id,c+1);

  for(int i=up;i<=down;i++){
    if( S[i][id] != ch && S[i][id] != '?' ) break;
    if( S[i][id] == '?' && c == 0 ) break;
    ret += ( solve(i+1,down,id,c + 1) * solve(up,i,id+1,0) ) % MOD;
    ret %= MOD;    
  }

  //  cout << up << " " << down << " " << id << " "<< c << " ( " << ch << " ) "  << S[up][id] << endl;  
  //    cout << ret << endl;
  return ret;
}

int main(){
  memset(dp,-1,sizeof(dp));
  cin >> N;
  int lenmax = 0;
  for(int i=0;i<N;i++){
    cin >> S[i];
    lenmax = max( lenmax, (int)S[i].size() );
  }
  for(int i=0;i<N;i++){
    while( (int)S[i].size() < lenmax ){    
      char c = 'a' - 1;
      S[i] += c;
    }
    // cout << S[i] << endl;
  }
  cout << solve(0,N-1,0,0) << endl;
}