How Many Strings Are Less

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

You are given a set DD of nn strings and a string ss. You need to find the number of strings in the set DD that are lexicographically less than ss.

The given string ss is modified qq times. Each modification is defined by a pair of an integer k_ik\_i and a character c_ic\_i. Modification (k_i,c_i)(k\_i, c\_i) means that all characters of the string ss, starting from k_ik\_i and up to the end of the string, are replaced by the character c_ic\_i.

For example, let the initial string ss be "anatoly", then the queries (5,o)(5, \mathtt{o}), (3, b)(3,  \mathtt{b}), (7,x)(7, \mathtt{x})  change the string as follows:

"anatoly" \to "anatooo" \to "anbbbbb" \to "anbbbbx"

After each modification of the string ss, you need to output the number of strings of the set DD that are lexicographically less than ss.

입력

The first line contains two integers nn and qq --- the number of strings of the set DD and the number of modifications (1n,q1061 \le n, q \le 10^6). 

The second line contains a string ss consisting of no more than 10610^6 lowercase Latin letters.

The following nn lines contain the strings of the set DD. Each string consists of lowercase Latin letters. The total length of the strings in DD does not exceed 10610^6.

The following qq lines contain descriptions of modifications. The description consists of the integer k_ik\_i and the lowercase letter of the English alphabet c_ic\_i, separated by a space (1k_is1 \le k\_i \le |s|).

출력

The first line of output must contain the number of strings of the set DD that are lexicographically less than the initial string ss.

Then output qq lines. In the ii-th line, print the answer after the ii-th modification.

힌트

In the first sample test, the string changes as follows:

"anatoly" \to "anatooo" \to "anbbbbb" \to "anbbbbx".

  • Initial string "anatoly" is lexicographically less than all the strings of the set, so the answer to the problem is 00.
  • After the first modification, the string becomes "anatooo" and there is an equal string in the set, but the answer to the problem is still 00, since it is not less than the current one.
  • Then the string becomes  "anbbbbb", which is lexicographically greater than "anatooo" and "anba", but less than  "anbbbbu" and "boris", so the answer is 22.
  • After the last modification, the line will become "anbbbbx", which is lexicographically greater than "anatooo", "anba" and "anbbbbu", the answer is 33.