Codeforces Round 299 (Div. 2)
D
Tavas and Malekas
Codeforces
1900
原题
← CE →
翻译中…

Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string $*s*$ of length $*n*$ comes out from Tavas' mouth instead.

翻译中…

image

翻译中…

Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on $*s*$. Malekas has a favorite string $*p*$. He determined all positions $*x*_{1} < *x*_{2} < ... < *x*_{*k*}$ where $*p*$ matches $*s*$. More formally, for each $*x*_{*i*}$ ($1 ≤ *i* ≤ *k*$) he condition $*s*_{*x*_{*i*}}*s*_{*x*_{*i*} + 1}... *s*_{*x*_{*i*} + |*p*| - 1} = *p*$ is fullfilled.

翻译中…

Then Malekas wrote down one of subsequences of $*x*_{1}, *x*_{2}, ... *x*_{*k*}$ (possibly, he didn't write anything) on a piece of paper. Here a sequence $*b*$ is a subsequence of sequence $*a*$ if and only if we can turn $*a*$ into $*b*$ by removing some of its elements (maybe no one of them or all).

翻译中…

After Tavas woke up, Malekas told him everything. He couldn't remember string $*s*$, but he knew that both $*p*$ and $*s*$ only contains lowercase English letters and also he had the subsequence he had written on that piece of paper.

翻译中…

Tavas wonders, what is the number of possible values of $*s*$? He asked SaDDas, but he wasn't smart enough to solve this. So, Tavas asked you to calculate this number for him.

翻译中…

Answer can be very large, so Tavas wants you to print the answer modulo $10^{9} + 7$.

翻译中…

Input

翻译中…

The first line contains two integers $*n*$ and $*m*$, the length of $*s*$ and the length of the subsequence Malekas wrote down ($1 ≤ *n* ≤ 10^{6}$ and $0 ≤ *m* ≤ *n* - |*p*| + 1$).

翻译中…

The second line contains string $*p*$ ($1 ≤ |*p*| ≤ *n*$).

翻译中…

The next line contains $*m*$ space separated integers $*y*_{1}, *y*_{2}, ..., *y*_{*m*}$, Malekas' subsequence ($1 ≤ *y*_{1} < *y*_{2} < ... < *y*_{*m*} ≤ *n* - |*p*| + 1$).

翻译中…

Output

翻译中…

In a single line print the answer modulo $1000 000 007$.

翻译中…

Note

翻译中…

In the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.

翻译中…

Here $|*x*|$ denotes the length of string x.

翻译中…

Please note that it's possible that there is no such string (answer is 0).

翻译中…

样例

Input #1
6 2
ioi
1 3
Output #1
26
InputCopy OutputCopy
Input #2
5 2
ioi
1 2
Output #2
0
InputCopy OutputCopy
题目信息
题号
535D
时间限制
2 s
内存限制
256 MB
标签
贪心
哈希
后缀结构
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。