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;
template <int n>
using AI = array<int, n>;
const double eps = 1e-9;
const int oo = 0x3F3F3F3F;
const long long ooLL = 0x3F3F3F3F3F3F3F3FLL;
const int MOD = 1000000007;
template <typename T>
T sqr(T x) {
  return x * x;
}
const double PI = acos(-1.);
long long Round(double x) { return x < 0 ? x - .5 : x + .5; }
int main() {
  void run();
  run();
  return 0;
}
const int N = 1 << 17, T = 75;
int n, q, h[N], hss;
pair<int, int> hs[N], ptl[N], ptr[N];
char s[N];
string a[N];
void rc() {
  for (int i = (0), _b(hss); i < _b; ++i) {
    int j = i;
    while (1) {
      if (j == 0 || hs[j - 1].first + 1 != hs[j].first) {
        ptl[i] = make_pair(-1, hs[j].first - 1);
        break;
      }
      if (hs[j - 1].second < hs[j].second) {
        ptl[i] = make_pair(j - 1, hs[j - 1].first);
        break;
      }
      if (ptl[j - 1].first == -1) {
        ptl[i] = ptl[j - 1];
        break;
      }
      j = ptl[j - 1].first;
      if (hs[j].second < hs[i].second) {
        ptl[i] = make_pair(j, hs[j].first);
        break;
      }
    }
  }
  for (int i = (hss - 1), _b(0); i >= _b; --i) {
    int j = i;
    while (1) {
      if (j + 1 == hss || hs[j + 1].first - 1 != hs[j].first) {
        ptr[i] = make_pair(-1, hs[j].first + 1);
        break;
      }
      if (hs[j + 1].second < hs[j].second) {
        ptr[i] = make_pair(j + 1, hs[j + 1].first);
        break;
      }
      if (ptr[j + 1].first == -1) {
        ptr[i] = ptr[j + 1];
        break;
      }
      j = ptr[j + 1].first;
      if (hs[j].second < hs[i].second) {
        ptr[i] = make_pair(j, hs[j].first);
        break;
      }
    }
  }
}
void addh(int p, int h) {
  if (h < T) return;
  pair<int, int> val(p, h);
  p = lower_bound(hs, hs + hss, val) - hs;
  for (int i = (hss - 1), _b(p); i >= _b; --i) hs[i + 1] = hs[i];
  hs[p] = val;
  ++hss;
  rc();
}
void rmh(int p, int h) {
  if (h < T) return;
  for (int i = (0), _b(hss); i < _b; ++i)
    if (hs[i].first == p) {
      for (int j = (i + 1), _b(hss); j < _b; ++j) hs[j - 1] = hs[j];
      --hss;
      break;
    }
  rc();
}
int gth(int l, int r) {
  int rs = 0;
  for (int i = (0), _b(hss); i < _b; ++i)
    if (l <= hs[i].first && hs[i].first < r) {
      int x = max(l, ptl[i].second + 1), y = min(r, ptr[i].second);
      rs = max(rs, (1 + y - x) * hs[i].second);
    }
  return rs;
}
void updh(int p) {
  rmh(p, h[p]);
  h[p] = 0;
  while (h[p] < a[p].size() && h[p] < a[p + 1].size() &&
         a[p][h[p]] == a[p + 1][h[p]])
    ++h[p];
  addh(p, h[p]);
}
struct S {
  int mh, rs[T], mxl[T], mxr[T], l;
};
S t[N << 1];
S mer(const S &a, const S &b) {
  S rs;
  rs.mh = max(a.mh, b.mh);
  for (int i = (0), _b(T); i < _b; ++i) {
    rs.mxl[i] = a.mxl[i] == a.l ? a.l + b.mxl[i] : a.mxl[i];
    rs.mxr[i] = b.mxr[i] == b.l ? b.l + a.mxr[i] : b.mxr[i];
    rs.rs[i] = max(a.rs[i], max(b.rs[i], a.mxr[i] + b.mxl[i]));
  }
  rs.l = a.l + b.l;
  return rs;
}
void asss(S &v, int h, int l) {
  v.mh = l;
  for (int i = (0), _b(T); i < _b; ++i) v.rs[i] = v.mxl[i] = v.mxr[i] = i <= h;
  v.l = 1;
}
void bld(int v, int l, int r) {
  if (l == r) return;
  if (l + 1 == r) {
    asss(t[v], h[l], a[l].size());
    return;
  }
  int m = l + (r - l) / 2;
  bld(v + v, l, m);
  bld(v + v + 1, m, r);
  t[v] = mer(t[v + v], t[v + v + 1]);
}
void upd(int v, int l, int r, int p) {
  if (l == r) return;
  if (l + 1 == r) {
    asss(t[v], h[l], a[l].size());
    return;
  }
  int m = l + (r - l) / 2;
  if (p < m)
    upd(v + v, l, m, p);
  else
    upd(v + v + 1, m, r, p);
  t[v] = mer(t[v + v], t[v + v + 1]);
}
S gt(int v, int l, int r, int lx, int rx) {
  if (lx <= l && r <= rx) return t[v];
  int m = l + (r - l) / 2;
  if (rx <= m) return gt(v + v, l, m, lx, rx);
  if (lx >= m) return gt(v + v + 1, m, r, lx, rx);
  return mer(gt(v + v, l, m, lx, rx), gt(v + v + 1, m, r, lx, rx));
}
void run() {
  if (0) {
    freopen("in.txt", "w", stdout);
    ;
    n = q = 1e5;
    printf("%d %d\n", n, q);
    for (int i = (0), _b(n); i < _b; ++i) printf("a ");
    puts("");
    for (int i = (0), _b(q); i < _b; ++i) printf("2 %d a\n", rand() % n + 1);
    exit(0);
  }
  scanf("%d %d\n", &n, &q);
  for (int i = (0), _b(n); i < _b; ++i) scanf("%s", s), a[i] = s;
  for (int i = (0), _b(n - 1); i < _b; ++i) updh(i);
  bld(1, 0, n - 1);
  for (int i = (0), _b(q); i < _b; ++i) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int l, r;
      scanf("%d %d", &l, &r);
      --l;
      int rs = a[r - 1].size();
      if (l + 1 < r) {
        S srs = gt(1, 0, n - 1, l, r - 1);
        for (int i = (0), _b(T); i < _b; ++i)
          rs = max(rs, (srs.rs[i] + (srs.rs[i] > 0)) * i);
        rs = max(rs, srs.mh);
      }
      rs = max(rs, gth(l, r - 1));
      printf("%d\n", rs);
    } else {
      int p;
      scanf("%d %s", &p, s);
      --p;
      a[p] = s;
      if (p) updh(p - 1), upd(1, 0, n - 1, p - 1);
      if (p + 1 < n) updh(p), upd(1, 0, n - 1, p);
    }
  }
}