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 N = 200010;
const int M = 11;
const int INF = 1 << 30;
const double EPS = 1e-8;
const int MOD = 1000000007LL;
int n, m, k, cnt;
string s;
struct Node {
  int d[M][M], fa, lt, rt, sl, sr, overrided;
  Node() {
    memset(d, 0, sizeof(d));
    fa = lt = rt = sl = sr = overrided = 0;
  }
};
Node tree[N * 2];
Node merge(Node lt, Node rt) {
  Node now;
  now.lt = lt.lt, now.rt = rt.rt;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; j++) {
      now.d[i][j] = lt.d[i][j] + rt.d[i][j];
    }
  }
  return now;
}
void build(int lt, int rt, int step, int fa) {
  tree[step].lt = lt, tree[step].rt = rt;
  tree[step].fa = fa;
  if (rt - lt <= 1) {
    int pl = s[lt] - 'a', pr = s[rt] - 'a';
    if (lt != rt) {
      tree[step].d[pl][pr] = 1;
    }
    return;
  }
  int md = (lt + rt) >> 1, sl = cnt + 1, sr = cnt + 2;
  cnt += 2;
  build(lt, md, sl, step);
  build(md, rt, sr, step);
  tree[step] = merge(tree[sl], tree[sr]);
  tree[step].sl = sl, tree[step].sr = sr;
  tree[step].fa = fa;
}
void updateVal(int step, int x, int y) {
  memset(tree[step].d, 0, sizeof(tree[step].d));
  tree[step].d[x][y] = tree[step].rt - tree[step].lt;
  tree[step].overrided = y + 1;
}
void pushDown(int step) {
  int c = tree[step].overrided;
  if (!c) {
    return;
  }
  c--;
  tree[step].overrided = 0;
  int md = (tree[step].lt + tree[step].rt) >> 1;
  if (tree[step].sl) {
    updateVal(tree[step].sl, c, c);
  }
  if (tree[step].sr) {
    updateVal(tree[step].sr, c, c);
  }
}
void pushUp(int step) {
  int sl = tree[step].sl, sr = tree[step].sr, fa = tree[step].fa;
  if (!sl || !sr) {
    return;
  }
  tree[step] = merge(tree[sl], tree[sr]);
  tree[step].sl = sl, tree[step].sr = sr;
  tree[step].fa = fa;
}
void update(int lt, int rt, int step, int x, int y) {
  if (tree[step].lt == lt && tree[step].rt == rt) {
    updateVal(step, x, y);
    return;
  }
  pushDown(step);
  int md = (tree[step].lt + tree[step].rt) >> 1;
  if (lt >= md) {
    update(lt, rt, tree[step].sr, x, y);
  } else if (rt <= md) {
    update(lt, rt, tree[step].sl, x, y);
  } else {
    update(lt, md, tree[step].sl, x, y);
    update(md, rt, tree[step].sr, x, y);
  }
  pushUp(step);
}
Node query(int lt, int rt, int step) {
  if (tree[step].lt == lt && tree[step].rt == rt) {
    return tree[step];
  }
  pushDown(step);
  int md = (tree[step].lt + tree[step].rt) >> 1;
  Node ret;
  if (lt >= md) {
    ret = query(lt, rt, tree[step].sr);
  } else if (rt <= md) {
    ret = query(lt, rt, tree[step].sl);
  } else {
    Node rl = query(lt, md, tree[step].sl);
    Node rr = query(md, rt, tree[step].sr);
    ret = merge(rl, rr);
  }
  pushUp(step);
  return ret;
}
pair<int, int> getP(int x) {
  Node now = query(x, x + 1, 0);
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; j++) {
      if (now.d[i][j]) {
        return make_pair(i, j);
      }
    }
  }
  return make_pair(-1, -1);
}
void processUpdate(int lt, int rt, int c) {
  int sl = lt == 0 ? lt : lt - 1;
  int sr = rt == n - 1 ? rt : rt + 1;
  if (lt != rt) {
    update(lt, rt, 0, c, c);
  }
  if (lt != sl) {
    pair<int, int> p = getP(sl);
    update(sl, lt, 0, p.first, c);
  }
  if (rt != sr) {
    pair<int, int> p = getP(rt);
    update(rt, sr, 0, c, p.second);
  }
}
void init() {
  memset(tree, 0, sizeof(tree));
  cin >> s;
  cnt = 0;
  build(0, n - 1, 0, -1);
}
char st[M];
int getAns(string xs) {
  Node now = query(0, n - 1, 0);
  int d[M][M] = {0};
  for (int i = 0; i < k; i++) {
    d[i][i] = 1;
    for (int j = i + 1; j < k; j++) {
      int x = xs[i] - 'a';
      int y = xs[j] - 'a';
      d[y][x] = 1;
    }
  }
  int ret = 0;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; j++) {
      if (d[i][j]) {
        ret += now.d[i][j];
      }
    }
  }
  return ret + 1;
}
void solve() {
  while (m--) {
    int op;
    scanf("%d", &op);
    if (op == 1) {
      int lt, rt;
      scanf("%d %d %s", &lt, &rt, st);
      lt--, rt--;
      int c = st[0] - 'a';
      processUpdate(lt, rt, c);
    } else {
      scanf("%s", st);
      cout << getAns(string(st)) << endl;
    }
  }
}
int main() {
  while (cin >> n >> m >> k) {
    init();
    solve();
  }
  return 0;
}