import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.Arrays; import java.util.NoSuchElementException; class Main { public static void main(String[] args) { new Main().run(); } void run() { solve(); } long mod=(long)1e9+7; int MAX=2000000; void solve() { FastScanner sc=new FastScanner(); PrintWriter pw=new PrintWriter(System.out); int N=sc.nextInt(); int[] A=new int[N]; for (int i=0;i[] dq=new ArrayDeque[m]; for (int i=0;i(); char[] cs=sc.next().toCharArray(); for (int i=0;i0 && cs[nxt]==cs[i-1]) { dp[nxt+1][0]+=dp[i][1]*(A[nxt]-1)%mod; dp[nxt+1][1]+=dp[i][1]; } else { dp[nxt+1][0]+=(dp[i][0]+dp[i][1])*(A[nxt]-1)%mod; dp[nxt+1][1]+=(dp[i][0]+dp[i][1])%mod; } dp[nxt+1][0]%=mod; dp[nxt+1][1]%=mod; } } long ans=0; for (int i=1;i