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.


-----Examples-----
Input
6 2
ioi
1 3

Output
26

Input
5 2
ioi
1 2

Output
0



-----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).

Difficulty: HARD
Tags: String algorithms

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
def solve():
	(n, m) = list(map(int, input().split()))
	p = input()
	if m == 0:
		return powmod(n)
	delta = len(p) - 1
	ys = list(map(int, input().split()))
	tail = 0
	free_chars = 0
	for y in ys:
		if y > tail:
			free_chars += y - tail - 1
		elif not is_consistent(p, tail - y + 1):
			return 0
		tail = y + delta
	free_chars += n - tail
	return powmod(free_chars)
ok_set = set()

def is_consistent(p, margin):
	nonlocal ok_set
	if margin in ok_set:
		return True
	elif p[:margin] == p[-margin:]:
		ok_set.add(margin)
		return True
	else:
		return False

def powmod(p):
	mod = 10 ** 9 + 7
	pbin = bin(p)[2:][-1::-1]
	result = 26 if pbin[0] == '1' else 1
	tmp = 26
	for bit in pbin[1:]:
		tmp *= tmp
		tmp %= mod
		if bit == '1':
			result *= tmp
			result %= mod
	return result
print(solve())


from sys import stdin, stdout, setrecursionlimit
input = stdin.readline
import string
characters = string.ascii_uppercase
from random import choice
inf = float('inf')
from functools import cmp_to_key
from collections import defaultdict as dd
from collections import Counter, deque
from heapq import *
import math
from math import floor, ceil, sqrt

def geti():
	return map(int, input().strip().split())

def getl():
	return list(map(int, input().strip().split()))

def getis():
	return map(str, input().strip().split())

def getls():
	return list(map(str, input().strip().split()))

def gets():
	return input().strip()

def geta():
	return int(input())

def print_s(s):
	stdout.write(s + '\n')
mod = int(1000000000.0 + 9)

def binary(a, b):
	res = 1
	while b:
		if b & 1:
			res *= a
			res %= mod
		a *= a
		a %= mod
		b //= 2
	return res

def solve():
	(n, m) = geti()
	ans = [choice(characters) for _ in range(n)]
	s = gets()
	k = len(s)
	a = getl()
	a = {i - 1: True for i in a}
	mod = int(1000000000.0 + 9)
	index = k
	for i in range(n):
		if i in a:
			index = 0
		if index < k:
			ans[i] = s[index]
			index += 1
	p = 31
	pow = 1
	hash = 0
	res = 0
	for i in range(k):
		hash += (ord(s[i]) - ord('a') + 1) * pow
		res += (ord(ans[i]) - ord('a') + 1) * pow
		hash %= mod
		res %= mod
		if i != k - 1:
			pow *= p
			pow %= mod
	if 0 in a:
		if hash != res:
			return 0
	div = binary(p, mod - 2)
	for i in range(k, n):
		res -= ord(ans[i - k]) - ord('a') + 1
		res *= div
		res %= mod
		res += (ord(ans[i]) - ord('a') + 1) * pow
		res %= mod
		if i - k + 1 in a and res != hash:
			return 0
	res = 1
	mod = int(1000000000.0 + 7)
	for i in ans:
		if i.isupper():
			res *= 26
			res %= mod
	return res
print(solve())


import sys

def prefix(s):
	m = len(s)
	v = [0] * len(s)
	for i in range(1, len(s)):
		k = v[i - 1]
		while k > 0 and s[k] != s[i]:
			k = v[k - 1]
		if s[k] == s[i]:
			k = k + 1
		v[i] = k
	w = set()
	i = m - 1
	while v[i] != 0:
		w.add(m - v[i])
		i = v[i] - 1
	return w
(n, m) = map(int, input().split())
if m == 0:
	print(pow(26, n, 1000000007))
	sys.exit(0)
p = input()
l = len(p)
x = list(map(int, input().split()))
w = prefix(p)
busy = l
for i in range(1, m):
	if x[i] - x[i - 1] < l and x[i] - x[i - 1] not in w:
		print(0)
		sys.exit(0)
	busy += min(x[i] - x[i - 1], l)
print(pow(26, n - busy, 1000000007))


def preZ(s):
	n = len(s)
	z = [0] * n
	z[0] = n
	r = 0
	if n == 1:
		return z
	while r + 1 < n and s[r] == s[r + 1]:
		r += 1
	z[1] = r
	l = 1 if r > 0 else 0
	for k in range(2, n):
		bl = r + 1 - k
		gl = z[k - l]
		if gl < bl:
			z[k] = z[k - l]
		else:
			j = max(0, r - k + 1)
			while k + j < n and s[j] == s[k + j]:
				j += 1
			z[k] = j
			(l, r) = (k, k + j - 1)
	return z
pp = int(1000000000.0) + 7

def binpow(b, e):
	r = 1
	while True:
		if e & 1:
			r = r * b % pp
		e = e >> 1
		if e == 0:
			break
		b = b * b % pp
	return r

def f(p, l, n):
	m = len(p)
	if len(l) == 0:
		return binpow(26, n)
	z = preZ(p)
	s = set([i for i in range(m) if z[i] + i == m])
	fc = l[0] - 1
	for i in range(1, len(l)):
		r = l[i - 1] + m
		if l[i] > r:
			fc += l[i] - r
			continue
		if l[i] < r and l[i] - l[i - 1] not in s:
			return 0
	fc += n - (l[-1] + m - 1)
	return binpow(26, fc)
(n, m) = list(map(int, input().split()))
p = input()
l = list(map(int, input().split())) if m > 0 else []
print(f(p, l, n))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import Counter, defaultdict
import math

def matching(s):
	le = len(s)
	pi = [0] * le
	for i in range(1, le):
		j = pi[i - 1]
		while j > 0 and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	w = set()
	i = le - 1
	while pi[i] != 0:
		w.add(le - pi[i])
		i = pi[i] - 1
	return w
(n, m) = map(int, input().split())
p = input()
if m == 0:
	print(pow(26, n, 10 ** 9 + 7))
	sys.exit()
arr = list(map(int, input().split()))
ans = 0
l = len(p)
pre = matching(p)
filled = l
for i in range(1, m):
	if arr[i] - arr[i - 1] < l and arr[i] - arr[i - 1] not in pre:
		print(0)
		sys.exit()
	filled += min(l, arr[i] - arr[i - 1])
print(pow(26, n - filled, 10 ** 9 + 7))