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;
const int MAXN = 101 * 1001, SQ = 55;
string s[MAXN];
int a[MAXN], b[MAXN];
int ans[MAXN], Ans[MAXN];
bool mark[MAXN];
struct query {
  int id, l, r;
} qu[3 * MAXN];
inline int lcp(int i) {
  int j = i + 1;
  int x = min(s[i].size(), s[j].size());
  int ans = 0;
  while (ans < x && s[i][ans] == s[j][ans]) ans++;
  return ans;
}
set<pair<int, int>> ss;
int prv[MAXN], nxt[MAXN];
int solve(int s, int e) {
  vector<int> st;
  st.push_back(s - 1);
  for (int i = s; i < e; i++) {
    while (st.size() > 1 && b[st.back()] >= b[i]) st.pop_back();
    prv[i] = st.back();
    st.push_back(i);
  }
  st.clear();
  st.push_back(e);
  int ans = 0;
  for (int i = e - 1; i >= s; i--) {
    while (st.size() > 1 && b[st.back()] >= b[i]) st.pop_back();
    nxt[i] = st.back();
    st.push_back(i);
    ans = max(ans, b[i] * (nxt[i] - prv[i]));
  }
  return ans;
}
pair<int, int> get(int i) {
  int s = i, e = i;
  while (s > -1 && mark[s]) s--;
  while (mark[e]) e++;
  return {s + 1, e};
}
void dlt(int i) {
  if (i < 0 || b[i] < SQ || !mark[i]) return;
  ss.erase(get(i));
  mark[i] = 0;
  if (i && mark[i - 1]) ss.insert(get(i - 1));
  if (mark[i + 1]) ss.insert(get(i + 1));
}
void ins(int i) {
  if (i < 0 || b[i] < SQ) return;
  if (i && mark[i - 1]) ss.erase(get(i - 1));
  if (mark[i + 1]) ss.erase(get(i + 1));
  mark[i] = 1;
  ss.insert(get(i));
}
int mx[4 * MAXN];
void Upd(int i, int val, int s = 0, int e = MAXN, int ind = 1) {
  if (e - s == 1) {
    mx[ind] = val;
    return;
  }
  int mid = (s + e) / 2;
  if (i < mid)
    Upd(i, val, s, mid, 2 * ind);
  else
    Upd(i, val, mid, e, 2 * ind + 1);
  mx[ind] = max(mx[2 * ind], mx[2 * ind + 1]);
}
int Get(int l, int r, int s = 0, int e = MAXN, int ind = 1) {
  if (l <= s && e <= r) return mx[ind];
  if (r <= s || e <= l) return 0;
  int mid = (s + e) / 2;
  return max(Get(l, r, s, mid, 2 * ind), Get(l, r, mid, e, 2 * ind + 1));
}
struct node {
  int ans, pre, suf, len;
} seg[4 * MAXN];
node bb;
node mrg(node a, node b) {
  node ans;
  ans.ans = max({a.ans, b.ans, a.suf + b.pre});
  ans.pre = (a.pre == a.len ? a.pre + b.pre : a.pre);
  ans.suf = (b.suf == b.len ? b.suf + a.suf : b.suf);
  ans.len = a.len + b.len;
  return ans;
}
void build(int s = 0, int e = MAXN, int ind = 1) {
  if (e - s == 1) {
    seg[ind] = {0, 0, 0, 1};
    return;
  }
  int mid = (s + e) / 2;
  build(s, mid, 2 * ind);
  build(mid, e, 2 * ind + 1);
  seg[ind] = mrg(seg[2 * ind], seg[2 * ind + 1]);
}
void upd(int i, int x, int s = 0, int e = MAXN, int ind = 1) {
  if (e - s == 1) {
    seg[ind] = {x, x, x, 1};
    return;
  }
  int mid = (s + e) / 2;
  if (i < mid)
    upd(i, x, s, mid, 2 * ind);
  else
    upd(i, x, mid, e, 2 * ind + 1);
  seg[ind] = mrg(seg[2 * ind], seg[2 * ind + 1]);
}
node get(int l, int r, int s = 0, int e = MAXN, int ind = 1) {
  if (l <= s && e <= r) return seg[ind];
  if (r <= s || e <= l) return bb;
  int mid = (s + e) / 2;
  return mrg(get(l, r, s, mid, 2 * ind), get(l, r, mid, e, 2 * ind + 1));
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  bb = {0, 0, 0, 0};
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n - 1; i++) b[i] = a[i] = lcp(i), ins(i);
  b[n - 1] = -100;
  int m = 0;
  vector<pair<int, int>> v;
  for (int i = 0; i < n; i++) Upd(i, s[i].size());
  for (int i = 0; i < q; i++) {
    int t;
    cin >> t;
    if (t == 1) {
      int l, r;
      cin >> l >> r;
      l--;
      qu[m++] = {-i - 1, l, r};
      r--;
      for (auto u : ss) {
        int s = u.first, e = u.second;
        if (r <= s || e <= l) continue;
        ans[i] = max(ans[i], solve(max(s, l), min(r, e)));
      }
      r++;
      ans[i] = max(ans[i], Get(l, r));
    }
    if (t == 2) {
      ans[i] = -1;
      string t;
      int x, v;
      cin >> x >> t;
      x--;
      s[x] = t;
      Upd(x, s[x].size());
      dlt(x), dlt(x - 1);
      if (x) b[x - 1] = lcp(x - 1), qu[m++] = {i, x - 1, b[x - 1]};
      if (x < n - 1) b[x] = lcp(x), qu[m++] = {i, x, b[x]};
      ins(x), ins(x - 1);
    }
  }
  for (int _ = 1; _ <= SQ; _++) {
    build();
    for (int i = 0; i < n - 1; i++) {
      upd(i, a[i] >= _);
      b[i] = a[i];
    }
    for (int i = 0; i < m; i++) {
      if (qu[i].id < 0) {
        int id = -(qu[i].id + 1);
        int l = qu[i].l, r = qu[i].r - 1;
        int val = get(l, r).ans;
        if (val > 0) val++;
        ans[id] = max(ans[id], val * _);
      } else {
        int id = qu[i].l;
        int v = qu[i].r;
        upd(id, b[id] >= _);
        b[id] = v;
        upd(id, b[id] >= _);
      }
    }
  }
  for (int i = 0; i < q; i++)
    if (ans[i] > -1) cout << ans[i] << '\n';
}