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;
template <class AT, class UT>
struct SegmentTree {
  AT I;
  UT NU, v;
  int N, l, r;
  vector<AT> A;
  vector<UT> U;
  vector<int> L, R;
  virtual AT op(const AT& i, const AT& j) = 0;
  virtual AT& us(int p, const UT& v) = 0;
  SegmentTree(int N, AT I = 0, UT NU = INT_MIN)
      : I(I), NU(NU), N(N), A(4 * N, I), U(4 * N, NU), L(4 * N), R(4 * N) {
    build(1, 0, N - 1);
  }
  void build(int p, int i, int j) {
    L[p] = i;
    R[p] = j;
    if (i != j) {
      build(2 * p, i, (i + j) / 2);
      build(2 * p + 1, (i + j) / 2 + 1, j);
    }
  }
  SegmentTree(const vector<AT>& data, AT I = 0, UT NU = INT_MIN)
      : I(I),
        NU(NU),
        N(data.size()),
        A(4 * N),
        U(4 * N, NU),
        L(4 * N),
        R(4 * N) {}
  AT& build(int p, int i, int j, const vector<AT>& data) {
    L[p] = i;
    R[p] = j;
    if (i == j) return A[p] = data[i];
    return A[p] = op(build(2 * p, i, (i + j) / 2, data),
                     build(2 * p + 1, (i + j) / 2 + 1, j, data));
  }
  AT update(int p) {
    if (l <= L[p] && R[p] <= r) return us(p, v);
    if (R[p] < l || r < L[p] || L[p] == R[p]) return v == NU ? I : A[p];
    us(2 * p, U[p]);
    us(2 * p + 1, U[p]);
    U[p] = NU;
    AT r = op(update(2 * p), update(2 * p + 1));
    if (v != NU) A[p] = r;
    return r;
  }
  AT update(int i, int j, UT k) {
    l = i;
    r = j;
    v = k;
    return j < i ? I : update(1);
  }
  AT query(int i, int j) { return update(i, j, NU); }
};
struct ARR : SegmentTree<char, char> {
  ARR(const vector<char>& data) : SegmentTree(data, 10, 10) {
    if (N) build(1, 0, N - 1, data);
  }
  char op(const char& i, const char& j) { return i == I ? j : i; }
  char& us(int p, const char& v) {
    if (v != NU) {
      A[p] = v;
      U[p] = v;
    }
    return A[p];
  }
};
int n, m, k;
string s;
struct CTS : SegmentTree<array<int, 100>, array<int, 5> > {
  CTS(const vector<array<int, 100> >& data)
      : SegmentTree(data, array<int, 100>(), {INT_MIN, 0, 0, 0, 0}) {
    if (N) build(1, 0, N - 1, data);
  }
  array<int, 100> op(const array<int, 100>& i, const array<int, 100>& j) {
    array<int, 100> r = i;
    for (int c = 0; c < 100; c++) r[c] += j[c];
    return r;
  }
  array<int, 100>& us(int p, const array<int, 5>& v) {
    if (v != NU) {
      array<int, 5> t = v;
      if (L[p] != t[3]) t[0] = t[1];
      if (R[p] != t[4]) t[2] = t[1];
      A[p].fill(0);
      int w = R[p] - L[p] + 1;
      if (w == 1) {
        A[p][k * t[0] + t[2]] = 1;
      } else {
        A[p][k * t[0] + t[1]]++;
        A[p][k * t[1] + t[2]]++;
        A[p][t[1] * (1 + k)] += w - 2;
      }
      U[p] = v;
    }
    return A[p];
  }
};
int main() {
  int i;
  char cc;
  ios::sync_with_stdio(false);
  cin >> n >> m >> k >> s;
  for (int c = 0; c < n; c++) s[c] -= 'a';
  array<int, 100> t;
  vector<array<int, 100> > data(n - 1);
  for (int c = 0; c < n - 1; c++) data[c][k * s[c] + s[c + 1]] = 1;
  ARR chars(vector<char>(s.begin(), s.end()));
  CTS cts(data);
  int x, y;
  for (int c = 0; c < m; c++) {
    cin >> i;
    if (i == 1) {
      cin >> x >> y >> cc;
      x--;
      y--;
      cc -= 'a';
      chars.update(x, y, cc);
      x--;
      if (x < 0) x++;
      if (y == n - 1) y--;
      cts.update(x, y,
                 {chars.query(x, x), cc, chars.query(y + 1, y + 1), x, y});
    } else {
      cin >> s;
      int r = 1;
      t = cts.query(0, n - 2);
      for (int i = 0; i < s.size(); i++)
        for (int j = i; j < s.size(); j++)
          r += t[(s[j] - 'a') * k + s[i] - 'a'];
      cout << r << endl;
    }
  }
  return 0;
}