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>
#pragma GCC optimize("O3")
using namespace std;
inline int getint() {
  int _x = 0;
  char _tc = getchar();
  while (_tc < '0' || _tc > '9') _tc = getchar();
  while (_tc >= '0' && _tc <= '9') _x *= 10, _x += (_tc - '0'), _tc = getchar();
  return _x;
}
int st[202020 << 1];
void modify(int no, int l, int r, int p, int x) {
  if (l == r) {
    st[no] = x;
    return;
  }
  if (p <= ((l + r) >> 1))
    modify((no << 1), l, ((l + r) >> 1), p, x);
  else
    modify((1 + (no << 1)), ((l + r) >> 1) + 1, r, p, x);
  st[no] = max(st[(no << 1)], st[(1 + (no << 1))]);
}
int query(int no, int l, int r, int ql, int qr) {
  if (r < ql or l > qr or ql > qr) return 0;
  if (ql <= l and r <= qr) return st[no];
  return max(query((no << 1), l, ((l + r) >> 1), ql, qr),
             query((1 + (no << 1)), ((l + r) >> 1) + 1, r, ql, qr));
}
struct Nd {
  int mxc, mxl, mxr;
  Nd *tl, *tr;
  Nd() {
    tl = tr = NULL;
    mxc = mxl = mxr = 0;
  }
};
Nd* root[202020];
int Con(Nd* now) { return now ? now->mxc : 0; }
int MXL(Nd* now) { return now ? now->mxl : 0; }
int MXR(Nd* now) { return now ? now->mxr : 0; }
void modify2(Nd* now, int l, int r, int pp, int xx) {
  if (l == r) {
    now->mxc = now->mxl = now->mxr = xx;
    return;
  }
  if (pp <= ((l + r) >> 1)) {
    if (!now->tl) now->tl = new Nd();
    modify2(now->tl, l, ((l + r) >> 1), pp, xx);
  } else {
    if (!now->tr) now->tr = new Nd();
    modify2(now->tr, ((l + r) >> 1) + 1, r, pp, xx);
  }
  now->mxl = MXL(now->tl);
  if (MXL(now->tl) == ((l + r) >> 1) - l + 1) now->mxl += MXL(now->tr);
  now->mxr = MXR(now->tr);
  if (MXR(now->tr) == r - ((l + r) >> 1)) now->mxr += MXR(now->tl);
  now->mxc = max(Con(now->tl), Con(now->tr));
  now->mxc = max(now->mxc, MXR(now->tl) + MXL(now->tr));
}
tuple<int, int, int> query2(Nd* now, int l, int r, int ql, int qr) {
  if (!now or (l == ql and r == qr))
    return make_tuple(Con(now), MXL(now), MXR(now));
  if (qr <= ((l + r) >> 1)) return query2(now->tl, l, ((l + r) >> 1), ql, qr);
  if (((l + r) >> 1) < ql)
    return query2(now->tr, ((l + r) >> 1) + 1, r, ql, qr);
  tuple<int, int, int> retl =
      query2(now->tl, l, ((l + r) >> 1), ql, ((l + r) >> 1));
  tuple<int, int, int> retr =
      query2(now->tr, ((l + r) >> 1) + 1, r, ((l + r) >> 1) + 1, qr);
  int rl = get<1>(retl);
  if (rl == ((l + r) >> 1) - ql + 1) rl += get<1>(retr);
  int rr = get<2>(retr);
  if (rr == qr - ((l + r) >> 1)) rr += get<2>(retl);
  int rc = max(get<0>(retl), get<0>(retr));
  rc = max(rc, get<2>(retl) + get<1>(retr));
  return make_tuple(rc, rl, rr);
}
char c[202020 + 202020 + 202020];
int n, q, ss[202020], len[202020], ptr;
void init() {
  n = getint();
  q = getint();
  for (int i = 1; i <= n; i++) {
    scanf("%s", c + ptr);
    ss[i] = ptr;
    len[i] = strlen(c + ptr);
    ptr += len[i] + 1;
  }
}
int lcp[202020];
set<pair<int, int> > s;
void update(int cur, bool first) {
  if (not first) {
    if (lcp[cur] > 222) s.erase({cur, lcp[cur]});
    for (int i = 1; i <= min(222, lcp[cur]); i++) {
      if (!root[i]) root[i] = new Nd();
      modify2(root[i], 1, n, cur, 0);
    }
  }
  lcp[cur] = 0;
  while (lcp[cur] < len[cur] and lcp[cur] < len[cur - 1] and
         c[ss[cur] + lcp[cur]] == c[ss[cur - 1] + lcp[cur]])
    lcp[cur]++;
  for (int i = 1; i <= min(222, lcp[cur]); i++) {
    if (!root[i]) root[i] = new Nd();
    modify2(root[i], 1, n, cur, 1);
  }
  if (lcp[cur] > 222) s.insert({cur, lcp[cur]});
}
long long query2(int li, int ri) {
  vector<pair<int, int> > vv;
  while (true) {
    auto it = s.lower_bound({li + 1, -1});
    if (it == s.end() or it->first > ri) break;
    vv.push_back(*it);
    li = it->first;
  }
  if (vv.empty()) return 0;
  vector<int> ltil, rtil;
  for (size_t i = 0; i < vv.size(); i++) {
    ltil.push_back(vv[i].first);
    rtil.push_back(vv[i].first);
  }
  vector<pair<int, int> > wt;
  wt.push_back({vv[0].first - 1, 0});
  for (size_t i = 0; i < vv.size(); i++) {
    while (wt.size() and wt.back().second >= vv[i].second) wt.pop_back();
    if (i and vv[i - 1].first + 1 < vv[i].first)
      wt.push_back({vv[i].first - 1, 0});
    ltil[i] = wt.back().first + 1;
    wt.push_back(vv[i]);
  }
  wt.clear();
  wt.push_back({vv.back().first + 1, 0});
  for (int i = (int)vv.size() - 1; i >= 0; i--) {
    while (wt.size() and wt.back().second >= vv[i].second) wt.pop_back();
    if (i + 1 < (int)vv.size() and vv[i + 1].first - 1 > vv[i].first)
      wt.push_back({vv[i].first + 1, 0});
    rtil[i] = wt.back().first - 1;
    wt.push_back(vv[i]);
  }
  long long ret = 0;
  for (size_t i = 0; i < vv.size(); i++) {
    long long tret = (long long)(rtil[i] - ltil[i] + 2) * vv[i].second;
    ret = max(ret, tret);
  }
  return ret;
}
void solve() {
  for (int i = 1; i <= n; i++) modify(1, 1, n, i, len[i]);
  for (int i = 2; i <= n; i++) update(i, true);
  while (q--) {
    int cmd = getint();
    if (cmd == 1) {
      int li = getint();
      int ri = getint();
      int mxlen = query(1, 1, n, li, ri);
      long long ans = mxlen;
      if (li < ri) {
        for (int i = 1; i <= min(222, mxlen); i++) {
          if (!root[i]) break;
          int ret = get<0>(query2(root[i], 1, n, li + 1, ri));
          if (ret == 0) break;
          ans = max(ans, (long long)(ret + 1) * i);
          if ((long long)(ret + 1) * mxlen <= ans) break;
        }
        ans = max(ans, query2(li, ri));
      }
      printf("%lld\n", ans);
    } else {
      int who = getint();
      scanf("%s", c + ptr);
      ss[who] = ptr;
      len[who] = strlen(c + ptr);
      ptr += len[who] + 1;
      modify(1, 1, n, who, len[who]);
      if (who > 1) update(who, false);
      if (who < n) update(who + 1, false);
    }
  }
}
int main() {
  init();
  solve();
}