题目描述
Background
HansBug, a novice, is in the English exam room, scratching his head countless times, but his mind remains blank.
Problem Description
HansBug, a novice, is faced with an English composition consisting of $M$ words. However, with his limited intelligence, he has hastily finished writing it. Now, with $40$ minutes left before the exam ends, he plans to estimate the value of this English composition. It is well-known that using advanced vocabulary in middle and high school English compositions can effectively enhance the article's value, thereby earning better scores. HansBug knows $N$ advanced words, denoted as $A_i$ (with a length of $L_i$, including numbers, uppercase, and lowercase letters), each with a value of $B_i$. Each occurrence of an advanced word can increase the composition's value by $B_i$. Unfortunately, HansBug's brain cells and RP are exhausted, so this crucial task falls to you!
Input Format
The first line contains two integers $N$ and $P$, where $N$ represents the number of advanced words HansBug knows, and $P$ is the modulus.
Lines $2$ to $N+1$ each contain a word $A_i$ (with a length of $L_i$) and an integer $B_i$, where $B_i (0 < B_i \le 10^5)$ represents the value of the word.
The subsequent lines until the end of the input form an English composition, consisting of $M$ words and several delimiters (delimiters include and are limited to ,, ., !, ?).
Output Format
One line containing an integer, which is the total value of the article modulo $P$.
Sample Input and Output
Sample Input #1
5 99
hansbug 1
kkksc03 2
yyy 3
absi2011 4
lzn 100
hansbug is a juruo!but absi2011 not.!?!
one day absi2011 laughed at yyy and hansbug.
then kkksc03 and lzn blamed him for that.
Sample Output #1
16
Sample Input #2
5 99
yyyy 1
kkksc03 2
yyy 3
absi2011 4
lzn 100
yyyy is a juruo!but absi2011 not.!?!
one day absi2011 laughed at yyy and yyyy.
then kkksc03 and lzn blamed him for that.
Sample Output #2
16
Notes
In Sample $1$, hansbug appears $2$ times, absi2011 appears $2$ times, yyy appears $1$ time, kkksc03 appears $1$ time, and lzn appears $1$ time. Therefore, the total value is $1 \times 2 + 2 \times 4 + 3 \times 1 + 4 \times 1 + 100 \times 1 = 115$, which modulo $99$ is $16$.
In Sample $2$, it is similar to Sample $1$, but note that the word yyyy should not be considered as yyy appearing twice. Remember, this is an English composition, and everything should be considered at the word level.
This problem is case-sensitive.
Data Range (let the maximum length of all words be $Lmax$):

输入格式
见题面 Input 部分
输出格式
见题面 Output 部分