CF535D.Tavas and Malekas

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on ss . Malekas has a favorite string pp . He determined all positions x_{1}<x_{2}<...<x_{k} where pp matches ss . More formally, for each xix_{i} ( 1<=i<=k1<=i<=k ) he condition sxisxi+1... sxi+p1=ps_{xi}s_{xi}+1...\ s_{xi}+|p|-1=p is fullfilled.

Then Malekas wrote down one of subsequences of x1,x2,... xkx_{1},x_{2},...\ x_{k} (possibly, he didn't write anything) on a piece of paper. Here a sequence bb is a subsequence of sequence aa if and only if we can turn aa into bb 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 ss , but he knew that both pp and ss 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 ss ? 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 109+710^{9}+7 .

输入格式

The first line contains two integers nn and mm , the length of ss and the length of the subsequence Malekas wrote down ( 1<=n<=1061<=n<=10^{6} and 0<=m<=np+10<=m<=n-|p|+1 ).

The second line contains string pp ( 1<=p<=n1<=|p|<=n ).

The next line contains mm space separated integers y1,y2,...,ymy_{1},y_{2},...,y_{m} , Malekas' subsequence ( 1<=y_{1}<y_{2}<...<y_{m}<=n-|p|+1 ).

输出格式

In a single line print the answer modulo 10000000071000000007 .

输入输出样例

  • 输入#1

    6 2
    ioi
    1 3
    

    输出#1

    26
    
  • 输入#2

    5 2
    ioi
    1 2
    

    输出#2

    0
    

说明/提示

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

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

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

首页