#include<bits/stdc++.h>
using namespace std;
map<string,long long int>ma;
map<string,long long int>::iterator it;
int main(){
int a,b,mod=1e9+7,ans=0;
string g;
cin>>a>>b;
for(int i=0;i<b;i++){
cin>>g;
ma[g]+=1;
}
for(int i=2;i<=a;i++){
for(int h=0;h<b;h++){
cin>>g;
string temp1=g.substr(0,i-1),temp2=g.substr(1,i-1);
if(temp1==temp2) ma[g]+=ma[temp1];
else ma[g]+=ma[temp1]+ma[temp2];
ma[g]%=mod;
}
}
for(it=ma.begin();it!=ma.end();it++){
if(it->first.size()==a){
ans+=it->second;
ans%=mod;
}
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |