#SGM0000049. Hoán vị bảng chữ cái (Alphabet Permutations)

Hoán vị bảng chữ cái (Alphabet Permutations)

Alphabet Permutations

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Maintain a string over the first kk letters. Range assignments modify the string. For a permutation pp, output the minimum number of repeated copies of pp needed so that the current string is a subsequence.

Input

The first line contains n,m,kn,m,k, followed by string ss. Then mm operations follow: 1 l r c assigns character cc on the range, while 2 p asks for d(p)d(p) for a permutation pp of the first kk letters.

Output

For every type-2 operation, print d(p)d(p).

Subtasks

  • Subtask 1 (20%): size and operation count at most 30; all other validity conditions are unchanged.

  • Subtask 2 (30%): size and operation count at most 3000; all other validity conditions are unchanged.

  • Subtask 3 (50%): full constraints:

  • 1≤n≤2⋅1051\le n\le2\cdot10^5

  • 1≤m≤200001\le m\le20000

  • 1≤k≤101\le k\le10

Examples

Input

7 4 3
abacaba
1 3 5 b
2 abc
1 4 4 c
2 cba

Output

6
5

Explanation

After the first assignment the string is abbbbba; permutation abc needs 6 copies. After the next assignment the string is abbcbba; permutation cba needs 5 copies.