'''
获取KMP next数组, next[i]表示的是以i-1位置结尾的子串的最长公共前后缀长度
'''
from typing import List
def getKmpNext(data : List) -> List[int]:
next = [0 for _ in range(len(data))]
next[0] = -1
j, k = 0, -1
while j < len(data)-1:
if k == -1 or data[j] == data[k]:
j, k = j+1, k+1
next[j] = k
else:
k = next[k]
return next
def matrix_mul(A, B, mod):
ans = [[0] * len(B[0]) for _ in range(len(A))]
for i in range(len(A)):
for j in range(len(B[0])):
acc_val = 0
for k in range(len(A[i])):
acc_val += A[i][k] * B[k][j]
ans[i][j] = acc_val % mod if mod is not None else acc_val
return ans
def matrix_pow(A, k, mod):
if k == 1:
return A
if k == 2:
return matrix_mul(A, A, mod)
t = matrix_pow(A, k >> 1, mod)
ans = matrix_mul(A, matrix_mul(t, t, mod), mod) if k % 2 == 1 else matrix_mul(t, t, mod)
#print(f'k = {k}, ans = {ans}')
return ans
n, m, mod = map(int, input().split())
T = input()
A = [[0] * m for _ in range(m)]
D = getKmpNext(T)
for j in range(m):
for ch in '0123456789':
if ch == T[j]:
if j+1 < m:
A[j+1][j] += 1
else:
k = j
while True:
if k == -1 or T[k] == ch:
A[k+1][j] += 1
break
else:
k = D[k]
if n == 1:
if m > 1:
print(10)
else:
print(9)
else:
AA = matrix_pow(A, n-1, mod)
if m == 1:
ans = (AA[0][0] * 9) % mod
print(ans)
else:
ans = 0
for line in AA:
ans += 9 * line[0] + line[1]
ans %= mod
print(ans)