#P2786. 英语1(eng1)- 英语作文
英语1(eng1)- 英语作文
Description
In front of "juruo" HansBug is an English essay. However, with his anxious IQ, HansBug has already scribbled a draft. He then notices there are still minutes left before the exam ends, so he decides to estimate the "value" (also called "gold content") of this English essay, which contains words in total. As we all know, using advanced vocabulary in English essays for entrance exams can effectively raise the essay’s "gold content", thus earning a better score. It is known that "juruo" HansBug knows advanced words, denoted as (each word has length and consists of digits and letters in both uppercase and lowercase). The "gold content" value of this advanced word is , meaning every occurrence of this word increases the total value by . But his brain cells and RP ("luck") are already exhausted, so this great task is left to you!
Input Format
- The first line contains two positive integers and , where is the number of advanced words HansBug knows, and is the modulus.
- The next lines each contain a word (of length ) and an integer , where satisfies , representing the value of that word.
- The following lines until the end of input form an English essay, which contains words in total, along with some separators (the separators include and only include
,,.,!,?).
Output Format
Output one line containing a single integer: the total value of the essay modulo .
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.
16
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.
16
Hint
In sample , there are occurrences of hansbug, of absi2011, of yyy, of kkksc03, and of lzn, so the total value is $1 \times 2 + 2 \times 4 + 3 \times 1 + 4 \times 1 + 100 \times 1 = 115$, and .
In sample , it is basically the same as sample . Note that the whole yyyy cannot be considered as yyy appearing times. Please note this is an English essay; treat the word as the smallest unit.
This problem is case-sensitive.
Constraints (let the maximum length of all words be ):
| Test point ID | |||
|---|---|---|---|
| ^ | |||
| ^ |
For all testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号