Sachin was investigating IPv6 addresses and the way they were compressed, and this gave him an idea for a new compression scheme. First, you have an address of $$$n$$$ hexadecimal characters. Hexadecimal characters are the digits $$$0-9$$$ and the letters $$$a-f$$$. They are separated into blocks of $$$k$$$ hexadecimal characters with colons in between blocks. To compress the string, perform the following process:
Sachin wants to know for a given string the smallest compression length. He also wants to see how changing the string affects the compression length, so he will give you multiple queries. In the $$$i$$$-th query, he will change all characters in the range $$$[l_i, r_i]$$$ in the string to the character $$$c_i$$$. After each query, report the smallest compression length.
The first line of input consists of two integers $$$n$$$ and $$$k$$$ $$$(1 \le k \le n \le 10^5)$$$ — the length of the string and the block size, respectively. It is guaranteed that $$$n$$$ is a multiple of $$$k$$$.
The second line of input consists of a string of $$$n$$$ characters, where each character is a hexadecimal character ($$$0-9,a-f$$$).
The third line of input consists of a single integer $$$q$$$ $$$(1 \le q \le 10^5)$$$ — the number of queries.
The next $$$q$$$ lines of input each consist of two integers $$$l_i$$$ and $$$r_i$$$ $$$(1 \le l_i \le r_i \le n)$$$, as well as a hexadecimal character $$$c_i$$$.
Output $$$q$$$ lines, where the $$$i$$$-th line consists of a single integer representing the smallest compression length of the string after processing the first $$$i$$$ queries.
8 20a80f2c352 3 04 6 e8 8 c2 5 52 7 9
7 8 8 7 4
After the first query in the example, the uncompressed string is 00:00:f2:c3. The optimal character to remove is '0', which results in ::f2:c3. Since there are no more than 2 colons in a row, no colons can be removed and the answer is 7.
After the fifth query in the example, the uncompressed string is 09:99:99:9c. The optimal character to remove is '9', which results in 0:::c. One colon needs to be removed, resulting in 0::c with a length of 4.
| Название |
|---|


