Problem: You are given a string s of length n, consisting of first k lowercase English letters.

We define a c-repeat of some string q as a string, consisting of c copies of the string q. For example, string "acbacbacbacb" is a 4-repeat of the string "acb".

Let's say that string a contains string b as a subsequence, if string b can be obtained from a by erasing some symbols.

Let p be a string that represents some permutation of the first k lowercase English letters. We define function d(p) as the smallest integer such that a d(p)-repeat of the string p contains string s as a subsequence.

There are m operations of one of two types that can be applied to string s:

  1. Replace all characters at positions from li to ri by a character ci. 
  2. For the given p, that is a permutation of first k lowercase English letters, find the value of function d(p). 



All operations are performed sequentially, in the order they appear in the input. Your task is to determine the values of function d(p) for all operations of the second type.

Input

The first line contains three positive integers n, m and k (1 ≤ n ≤ 200 000, 1 ≤ m ≤ 20000, 1 ≤ k ≤ 10) — the length of the string s, the number of operations and the size of the alphabet respectively. The second line contains the string s itself.

Each of the following lines m contains a description of some operation: 

  1. Operation of the first type starts with 1 followed by a triple li, ri and ci, that denotes replacement of all characters at positions from li to ri by character ci (1 ≤ li ≤ ri ≤ n, ci is one of the first k lowercase English letters). 
  2. Operation of the second type starts with 2 followed by a permutation of the first k lowercase English letters.

Output

For each query of the second type the value of function d(p).

Examples

Input

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


Output

6
5

Note

After the first operation the string s will be abbbbba.

In the second operation the answer is 6-repeat of abc: ABcaBcaBcaBcaBcAbc.

After the third operation the string s will be abbcbba.

In the fourth operation the answer is 5-repeat of cba: cbAcBacBaCBacBA.

Uppercase letters means the occurrences of symbols from the string s.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x7fffffff;
const long long Linf = 1ll << 61;
const double EPS = 1e-10;
namespace IOSpace {
void get_int(int &x) {
  char t = getchar();
  bool neg = false;
  x = 0;
  for (; (t > '9' || t < '0') && t != '-'; t = getchar())
    ;
  if (t == '-') neg = true, t = getchar();
  for (; t <= '9' && t >= '0'; t = getchar()) x = x * 10 + t - '0';
  if (neg) x = -x;
}
void get_int(long long &x) {
  char t = getchar();
  bool neg = false;
  x = 0;
  for (; (t > '9' || t < '0') && t != '-'; t = getchar())
    ;
  if (t == '-') neg = true, t = getchar();
  for (; t <= '9' && t >= '0'; t = getchar()) x = x * 10 + t - '0';
  if (neg) x = -x;
}
void print_int(int x) {
  if (x < 0) putchar('-'), x = -x;
  short a[20] = {}, sz = 0;
  while (x > 0) a[sz++] = x % 10, x /= 10;
  if (sz == 0) putchar('0');
  for (int i = sz - 1; i >= 0; i--) putchar('0' + a[i]);
}
void print_int(long long x) {
  if (x < 0) putchar('-'), x = -x;
  short a[20] = {}, sz = 0;
  while (x > 0) a[sz++] = x % 10, x /= 10;
  if (sz == 0) putchar('0');
  for (int i = sz - 1; i >= 0; i--) putchar('0' + a[i]);
}
}  // namespace IOSpace
using namespace IOSpace;
const int maxlog = 20;
const long long mod = 1000000007;
const int maxn = 200005;
int a[maxn], n, m, k;
struct SGT {
  struct segment {
    int l, r, cnt[10][10], change, left, right;
  };
  segment seg[555555];
  void maintain(int t) {
    for (int i = 0; i < k; i++)
      for (int j = 0; j < k; j++)
        seg[t].cnt[i][j] =
            seg[(t << 1)].cnt[i][j] + seg[((t << 1) | 1)].cnt[i][j];
    seg[t].left = seg[(t << 1)].left;
    seg[t].right = seg[((t << 1) | 1)].right;
    seg[t].cnt[seg[(t << 1)].right][seg[((t << 1) | 1)].left]++;
  }
  void pushdown(int t) {
    if (seg[t].change != -1) {
      seg[(t << 1)].change = seg[((t << 1) | 1)].change = seg[t].left =
          seg[t].right = seg[(t << 1)].left = seg[(t << 1)].right =
              seg[((t << 1) | 1)].left = seg[((t << 1) | 1)].right =
                  seg[t].change;
      memset((seg[(t << 1)].cnt), (0), sizeof(seg[(t << 1)].cnt));
      seg[(t << 1)].cnt[seg[t].change][seg[t].change] =
          seg[(t << 1)].r - seg[(t << 1)].l;
      memset((seg[((t << 1) | 1)].cnt), (0), sizeof(seg[((t << 1) | 1)].cnt));
      seg[((t << 1) | 1)].cnt[seg[t].change][seg[t].change] =
          seg[((t << 1) | 1)].r - seg[((t << 1) | 1)].l;
      seg[t].change = -1;
    }
  }
  void build(int l, int r, int t) {
    seg[t].l = l;
    seg[t].r = r;
    seg[t].change = -1;
    seg[t].left = a[l];
    seg[t].right = a[r];
    memset((seg[t].cnt), (0), sizeof(seg[t].cnt));
    if (l == r) return;
    build(l, ((seg[t].l + seg[t].r) >> 1), (t << 1));
    build(((seg[t].l + seg[t].r) >> 1) + 1, r, ((t << 1) | 1));
    maintain(t);
  }
  void change(int l, int r, int t, int v) {
    if (seg[t].l == l && seg[t].r == r) {
      seg[t].change = v;
      memset((seg[t].cnt), (0), sizeof(seg[t].cnt));
      seg[t].cnt[v][v] = r - l;
      seg[t].left = seg[t].right = v;
      return;
    }
    pushdown(t);
    if (r <= ((seg[t].l + seg[t].r) >> 1))
      change(l, r, (t << 1), v);
    else if (l > ((seg[t].l + seg[t].r) >> 1))
      change(l, r, ((t << 1) | 1), v);
    else {
      change(l, ((seg[t].l + seg[t].r) >> 1), (t << 1), v);
      change(((seg[t].l + seg[t].r) >> 1) + 1, r, ((t << 1) | 1), v);
    }
    maintain(t);
  }
};
SGT sgt;
char s[maxn];
int main() {
  get_int(n), get_int(m), get_int(k);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) a[i] = s[i] - 'a';
  sgt.build(1, n, 1);
  int op, l, r;
  char t[15];
  for (int i = 1; i <= m; i++) {
    get_int(op);
    if (op == 1) {
      scanf("%d%d%s", &l, &r, t);
      sgt.change(l, r, 1, t[0] - 'a');
    } else {
      scanf("%s", t);
      int ans = 1;
      for (int i = 0; i < k; i++)
        for (int j = 0; j <= i; j++)
          ans += sgt.seg[1].cnt[t[i] - 'a'][t[j] - 'a'];
      printf("%d\n", ans);
    }
  }
  return 0;
}