Problem: Mahmoud and Ehab solved Dr. Evil's questions so he gave them the password of the door of the evil land. When they tried to open the door using it, the door gave them a final question to solve before they leave (yes, the door is digital, Dr. Evil is modern). If they don't solve it, all the work will be useless and they won't leave the evil land forever. Will you help them?

Mahmoud and Ehab are given n strings s1, s2, ... , sn numbered from 1 to n and q queries, Each query has one of the following forms:

  * 1 a b (1 ≤ a ≤ b ≤ n), For all the intervals [l;r] where (a ≤ l ≤ r ≤ b) find the maximum value of this expression:

(r - l + 1) * LCP(sl, sl + 1, ... , sr - 1, sr) where LCP(str1, str2, str3, ... ) is the length of the longest common prefix of the strings str1, str2, str3, ... .

  * 2 x y (1 ≤ x ≤ n) where y is a string, consisting of lowercase English letters. Change the string at position x to y.

Input

The first line of input contains 2 integers n and q (1 ≤ n ≤ 105, 1 ≤ q ≤ 105) – The number of strings and the number of queries, respectively.

The second line contains n strings stri consisting of lowercase English letters.

The next q lines describe the queries and may have one of the 2 forms:

  * 1 a b (1 ≤ a ≤ b ≤ n).
  * 2 x y (1 ≤ x ≤ n), where y is a string consisting of lowercase English letters.



the total length of all strings in input won't exceed 105

Output

For each query of first type output its answer in a new line.

Example

Input

5 9
mahmoud mahmoudbadawy drmahmoud drevil mahmoud
1 1 5
1 1 2
1 2 3
2 3 mahmoud
2 4 mahmoud
2 2 mahmouu
1 1 5
1 2 3
1 1 1


Output

14
14
13
30
12
7

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
char str[700000];
int Max[700000], L[700000], R[700000], ls[700000], rs[700000], root[700000],
    tot = 0, lcp[700000], n, last[700000], a[700000], sta[700000], tmp[700000];
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
vector<int> vec[700000];
namespace Tree {
int mx[700000];
inline void update(int l, int r, int x, int p) {
  if (l == r) {
    mx[x] = vec[p].size();
    return;
  }
  int mid = (l + r) >> 1;
  if (p <= mid)
    update(l, mid, x << 1, p);
  else
    update(mid + 1, r, x << 1 | 1, p);
  mx[x] = max(mx[x << 1], mx[x << 1 | 1]);
}
inline int query(int l, int r, int x, int ll, int rr) {
  if (ll <= l && r <= rr) return mx[x];
  int mid = (l + r) >> 1, res = 0;
  if (ll <= mid) res = max(res, query(l, mid, x << 1, ll, rr));
  if (rr > mid) res = max(res, query(mid + 1, r, x << 1 | 1, ll, rr));
  return res;
}
};  // namespace Tree
inline int find(int x) {
  int i;
  for (i = 0; i < min(vec[x].size(), vec[x - 1].size()); ++i)
    if (vec[x][i] != vec[x - 1][i]) return i;
  return min(vec[x].size(), vec[x - 1].size());
}
inline void pushup(int x, int l, int r) {
  int mid = (l + r) >> 1;
  Max[x] = max(R[ls[x]] + L[rs[x]], max(Max[ls[x]], Max[rs[x]]));
  L[x] = L[ls[x]], R[x] = R[rs[x]];
  if (L[ls[x]] == (mid - l + 1)) L[x] += L[rs[x]];
  if (R[rs[x]] == (r - mid)) R[x] += R[ls[x]];
}
inline void update(int &x, int l, int r, int p, int opt) {
  if (!x) x = ++tot;
  if (l == r) {
    Max[x] = L[x] = R[x] = opt;
    return;
  }
  int mid = (l + r) >> 1;
  if (p <= mid)
    update(ls[x], l, mid, p, opt);
  else
    update(rs[x], mid + 1, r, p, opt);
  pushup(x, l, r);
}
inline void modify(int x, int opt) {
  int i, p = 0;
  if (lcp[x] <= 70) {
    for (i = 1; i <= lcp[x]; ++i) update(root[i], 1, n, x, opt);
  } else if (!opt) {
    for (i = 1; i <= 70; ++i) update(root[i], 1, n, x, 0);
    p = 0;
    while (last[p] != x) p = last[p];
    last[p] = last[x], last[x] = 0;
  } else {
    for (i = 1; i <= 70; ++i) update(root[i], 1, n, x, 1);
    p = 0;
    while (last[p] && last[p] < x) p = last[p];
    last[x] = last[p], last[p] = x;
  }
}
inline int query(int x, int l, int r, int ll, int rr) {
  if (!x) return 0;
  if (ll <= l && r <= rr) return Max[x];
  int mid = (l + r) >> 1, res = 0;
  if (ll <= mid) res = max(res, query(ls[x], l, mid, ll, rr));
  if (rr > mid) res = max(res, query(rs[x], mid + 1, r, ll, rr));
  if (ll <= mid && rr > mid)
    res = max(res, min(R[ls[x]], mid - ll + 1) + min(L[rs[x]], rr - mid));
  return res;
}
inline int solve(int l, int r) {
  int p = 0, num = 0, top = 0, i, res = 0;
  while (last[p]) p = last[p], a[++num] = p, num -= (p < l || p > r);
  sta[0] = a[1] - 1;
  for (i = 1; i <= num; ++i) {
    if (top && a[i] != sta[top] + 1) top = 0, sta[0] = a[i] - 1;
    while (top && lcp[a[i]] <= lcp[sta[top]]) --top;
    tmp[i] = sta[top], sta[++top] = a[i];
  }
  top = 0, sta[0] = a[num] + 1;
  for (i = num; i; --i) {
    if (top && a[i] != sta[top] - 1) top = 0, sta[0] = a[i] + 1;
    while (top && lcp[a[i]] <= lcp[sta[top]]) --top;
    res = max(res, lcp[a[i]] * (sta[top] - tmp[i]));
    sta[++top] = a[i];
  }
  return res;
}
int main() {
  int q, lens, l, r, j, i, opt, w, ans = 0, x;
  n = read(), q = read();
  for (i = 1; i <= n; ++i) {
    scanf("%s", str + 1), lens = strlen(str + 1);
    for (j = 1; j <= lens; ++j) vec[i].push_back(str[j] - 'a');
    Tree::update(1, n, 1, i);
    lcp[i] = find(i);
    modify(i, 1);
  }
  while (q--) {
    opt = read();
    if (opt == 1) {
      l = read(), r = read();
      ans = Tree::query(1, n, 1, l, r);
      if (l == r) {
        printf("%d\n", ans);
        continue;
      }
      for (i = 1; i <= 70; ++i)
        w = query(root[i], 1, n, l + 1, r),
        ans = max(ans, i * (w > 0 ? w + 1 : 0));
      ans = max(ans, solve(l + 1, r));
      printf("%d\n", ans);
    } else {
      x = read(), scanf("%s", str + 1), lens = strlen(str + 1);
      vec[x].clear();
      for (i = 1; i <= lens; ++i) vec[x].push_back(str[i] - 'a');
      Tree::update(1, n, 1, x);
      modify(x, 0), lcp[x] = find(x), modify(x, 1);
      if (x == n) continue;
      modify(x + 1, 0), lcp[x + 1] = find(x + 1), modify(x + 1, 1);
    }
  }
  return 0;
}