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;
#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
const int maxn = 1e5 + 10, maxm = 1e3 + 10, lg = 17, mod = 1e9 + 7, inf = 1e18;
struct node {
  int mxm, pre, suf;
  bool por;
  node(int mxm = 0, int pre = 0, int suf = 0, bool por = 0)
      : mxm(mxm), pre(pre), suf(suf), por(por) {}
} seg[maxn << 1];
int n, q, T[maxn], L[maxn], R[maxn], B[maxn], BB[maxn][2], ans[maxn];
string s[maxn];
vector<int> cum;
int lcp(string &a, string &b) {
  for (int i = 0; i < (int)(a.size()) && i < (int)(b.size()); i++)
    if (a[i] != b[i]) return i;
  return min((int)(a.size()), (int)(b.size()));
}
node mrg(node &n1, node &n2) {
  return node(max({n1.mxm, n2.mxm, n1.suf + n2.pre}), n1.pre + n1.por * n2.pre,
              n2.suf + n2.por * n1.suf, n1.por & n2.por);
}
void goz(int i, bool b) {
  seg[i += n] = node(b, b, b, b);
  for (i >>= 1; i; i >>= 1) seg[i] = mrg(seg[(i << 1)], seg[((i << 1) ^ 1)]);
}
int boz(int l, int r) {
  node lef = {0, 0, 0, 1}, rig = {0, 0, 0, 1};
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) lef = mrg(lef, seg[l++]);
    if (r & 1) rig = mrg(seg[--r], rig);
  }
  return mrg(lef, rig).mxm;
}
int kirnamoosankir[maxn << 1];
void gozkiri(int i, int x) {
  for (kirnamoosankir[i += n] = x; i > 1; i >>= 1)
    kirnamoosankir[i >> 1] = max(kirnamoosankir[i], kirnamoosankir[i ^ 1]);
}
int getkiri(int l, int r) {
  int ret = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) ret = max(ret, kirnamoosankir[l++]);
    if (r & 1) ret = max(ret, kirnamoosankir[--r]);
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> s[i], gozkiri(i, (int)(s[i].size()));
  for (int i = n - 1; i >= 1; i--)
    B[i] = lcp(s[i], s[i + 1]), cum.push_back(B[i]);
  for (int i = 0; i < q; i++) {
    cin >> T[i] >> L[i];
    if (T[i] == 1)
      cin >> R[i], ans[i] = getkiri(L[i], R[i] + 1);
    else
      cin >> s[L[i]], gozkiri(L[i], (int)(s[L[i]].size())),
          BB[i][0] = lcp(s[L[i] - 1], s[L[i]]),
          BB[i][1] = lcp(s[L[i]], s[L[i] + 1]), cum.push_back(BB[i][0]),
          cum.push_back(BB[i][1]);
  }
  sort(cum.begin(), cum.end()),
      cum.resize(unique(cum.begin(), cum.end()) - cum.begin());
  for (auto h : cum)
    if (h != 0) {
      for (int i = 1; i < n; i++) goz(i, B[i] >= h);
      for (int i = 0; i < q; i++) {
        if (T[i] == 1) {
          int kirkharnadaribekharbokontookoonetmike = boz(L[i], R[i]);
          if (kirkharnadaribekharbokontookoonetmike)
            kirkharnadaribekharbokontookoonetmike++;
          ans[i] = max(ans[i], kirkharnadaribekharbokontookoonetmike * h);
        } else {
          if (L[i] - 1) goz(L[i] - 1, BB[i][0] >= h);
          if (L[i] < n) goz(L[i], BB[i][1] >= h);
        }
      }
    }
  for (int i = 0; i < q; i++)
    if (T[i] == 1) cout << ans[i] << '\n';
  return 0;
}