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 MOD = 1e9 + 7;
const int SIZE = 1 << 17;
string s[SIZE];
int h[SIZE];
int ma[SIZE * 2 + 100];
vector<pair<int, int> > stkL[SIZE * 2 + 100], stkR[SIZE * 2 + 100];
void pre(int n) {
  for (int i = (2); i < (n + 1); ++i) {
    while (h[i] < min(((int)(s[i - 1]).size()), ((int)(s[i]).size())) &&
           s[i - 1][h[i]] == s[i][h[i]])
      h[i]++;
  }
}
int sid;
void pull(int id, int mm_v, int idL = 0, int idR = 0) {
  if (idL == 0) idL = id * 2;
  if (idR == 0) idR = id * 2 + 1;
  ma[id] = max(ma[idL], ma[idR]);
  int itR = 0, itL = 0;
  int num = 0;
  while (itR < ((int)(stkR[idL]).size()) && stkR[idL][itR].first >= mm_v)
    num += stkR[idL][itR++].second;
  while (itL < ((int)(stkL[idR]).size()) && stkL[idR][itL].first >= mm_v)
    num += stkL[idR][itL++].second;
  ma[id] = max(ma[id], num * mm_v);
  while (itR < ((int)(stkR[idL]).size()) && itL < ((int)(stkL[idR]).size())) {
    if (stkR[idL][itR] >= stkL[idR][itL]) {
      num += stkR[idL][itR].second;
      ma[id] = max(ma[id], num * stkR[idL][itR++].first);
    } else {
      num += stkL[idR][itL].second;
      ma[id] = max(ma[id], num * stkL[idR][itL++].first);
    }
  }
  while (itR < ((int)(stkR[idL]).size())) {
    num += stkR[idL][itR].second;
    ma[id] = max(ma[id], num * stkR[idL][itR++].first);
  }
  while (itL < ((int)(stkL[idR]).size())) {
    num += stkL[idR][itL].second;
    ma[id] = max(ma[id], num * stkL[idR][itL++].first);
  }
  stkL[id] = stkL[idL];
  stkL[id].resize(((int)(stkL[idL]).size()) + ((int)(stkL[idR]).size()));
  itL = ((int)(stkL[idL]).size());
  int now_v = min(stkL[idL].back().first, mm_v);
  int it = 0;
  int sp_num = 0;
  while (it < ((int)(stkL[idR]).size()) && stkL[idR][it].first >= now_v) {
    sp_num += stkL[idR][it++].second;
  }
  if (sp_num) {
    if (now_v == stkL[idL].back().first) {
      stkL[id][((int)(stkL[idL]).size()) - 1].second += sp_num;
    } else {
      stkL[id][itL++] = make_pair(now_v, sp_num);
    }
    sp_num = 0;
  }
  for (; it < ((int)(stkL[idR]).size()); it++) stkL[id][itL++] = stkL[idR][it];
  stkL[id].resize(itL);
  stkR[id] = stkR[idR];
  stkR[id].resize(((int)(stkR[idL]).size()) + ((int)(stkR[idR]).size()));
  itR = ((int)(stkR[idR]).size());
  now_v = min(stkR[idR].back().first, mm_v);
  it = 0;
  while (it < ((int)(stkR[idL]).size()) && stkR[idL][it].first >= now_v) {
    sp_num += stkR[idL][it++].second;
  }
  if (sp_num) {
    if (now_v == stkR[idR].back().first) {
      stkR[id][((int)(stkR[idR]).size()) - 1].second += sp_num;
    } else {
      stkR[id][itR++] = make_pair(now_v, sp_num);
    }
    sp_num = 0;
  }
  for (; it < ((int)(stkR[idL]).size()); it++) stkR[id][itR++] = stkR[idL][it];
  stkR[id].resize(itR);
}
void build(int L, int R, int id) {
  int mm = (L + R) / 2;
  if (L == R) {
    ma[id] = ((int)(s[L]).size());
    stkL[id] = stkR[id] = vector<pair<int, int> >(1, make_pair(ma[id], 1));
    return;
  }
  build(L, mm, id * 2);
  build(mm + 1, R, id * 2 + 1);
  pull(id, h[mm + 1]);
}
void print(string name, vector<pair<int, int> >& x) {
  printf("[%s:", name.c_str());
  for (int i = 0; i < (((int)(x).size())); ++i)
    printf("(%d,%d)%c", x[i].first, x[i].second,
           ",]"[i == ((int)(x).size()) - 1]);
  puts("");
}
int qq(int L, int R, int id, int ll, int rr, int rid) {
  if (R < ll || L > rr) {
    stkL[rid] = stkR[rid] = vector<pair<int, int> >();
    ma[rid] = 0;
    return 0;
  }
  if (L >= ll && R <= rr) {
    stkR[rid] = stkR[id];
    stkL[rid] = stkL[id];
    ma[rid] = ma[id];
    return ma[id];
  }
  int mm = (L + R) / 2;
  if (rr <= mm) return qq(L, mm, id * 2, ll, rr, rid);
  if (ll > mm) return qq(mm + 1, R, id * 2 + 1, ll, rr, rid);
  int ridL = sid++;
  int ridR = sid++;
  int ret = max(qq(L, mm, id * 2, ll, rr, ridL),
                qq(mm + 1, R, id * 2 + 1, ll, rr, ridR));
  pull(rid, h[mm + 1], ridL, ridR);
  ret = max(ret, ma[rid]);
  return ret;
}
void edit(int L, int R, int id, int x) {
  if (L == R) {
    ma[id] = ((int)(s[L]).size());
    stkL[id] = stkR[id] = vector<pair<int, int> >(1, make_pair(ma[id], 1));
    return;
  }
  int mm = (L + R) / 2;
  if (x <= mm)
    edit(L, mm, id * 2, x);
  else
    edit(mm + 1, R, id * 2 + 1, x);
  pull(id, h[mm + 1]);
}
void update(int x, int n) {
  cin >> s[x];
  for (int i = (max(2, x)); i < (min(x + 1, n) + 1); ++i) {
    h[i] = 0;
    while (h[i] < min(((int)(s[i - 1]).size()), ((int)(s[i]).size())) &&
           s[i - 1][h[i]] == s[i][h[i]])
      h[i]++;
  }
  edit(1, n, 1, x);
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = (1); i < (n + 1); ++i) cin >> s[i];
  pre(n);
  build(1, n, 1);
  for (int ker = 0; ker < (q); ++ker) {
    int(ty);
    scanf("%d", &ty);
    if (ty == 1) {
      int x, y;
      scanf("%d%d", &x, &y);
      sid = SIZE * 2;
      printf("%d\n", qq(1, n, 1, x, y, sid++));
    } else {
      int(x);
      scanf("%d", &x);
      update(x, n);
    }
  }
  return 0;
}