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;
int N, Q;
string S[100005];
char Str[100005];
int X[100005];
int Left[45][400005], Right[45][400005], Arb[45][400005];
int Arb2[400005];
const int limit = 40;
int Right2, ans;
set<int> P;
int Next[100005], Prev[100005];
int Aux[100005], Stack[100005];
void Read() {
  scanf("%d%d ", &N, &Q);
  for (int i = 1; i <= N; i++) {
    scanf("%s", Str);
    S[i] += (Str);
  }
}
int LCP(int a, int b) {
  int i, j;
  for (i = 0, j = 0; i < S[a].size() && j < S[b].size() && S[a][i] == S[b][j];
       i++, j++)
    ;
  return i;
}
void buildX() {
  for (int i = 1; i < N; i++) {
    X[i] = LCP(i, i + 1);
    if (X[i] > limit) P.insert(i);
  }
}
void buildTree(int val, int K, int L, int R) {
  if (L == R) {
    if (X[L] >= val) {
      Arb[val][K] = Left[val][K] = Right[val][K] = 1;
    } else
      Arb[val][K] = Left[val][K] = Right[val][K] = 0;
    return;
  }
  buildTree(val, K * 2, L, (L + R) / 2);
  buildTree(val, K * 2 + 1, (L + R) / 2 + 1, R);
  Arb[val][K] = max(Arb[val][K * 2], Arb[val][K * 2 + 1]);
  Arb[val][K] = max(Arb[val][K], Right[val][K * 2] + Left[val][K * 2 + 1]);
  if (Left[val][K * 2] == (L + R) / 2 - L + 1)
    Left[val][K] = Left[val][K * 2] + Left[val][K * 2 + 1];
  else
    Left[val][K] = Left[val][K * 2];
  if (Right[val][K * 2 + 1] == R - (L + R) / 2)
    Right[val][K] = Right[val][K * 2] + Right[val][K * 2 + 1];
  else
    Right[val][K] = Right[val][K * 2 + 1];
}
void buildTree2(int K, int L, int R) {
  if (L == R) {
    Arb2[K] = S[L].size();
    return;
  }
  buildTree2(K * 2, L, (L + R) / 2);
  buildTree2(K * 2 + 1, (L + R) / 2 + 1, R);
  Arb2[K] = max(Arb2[K * 2], Arb2[K * 2 + 1]);
}
void Update(int val, int K, int L, int R, int pos, int v) {
  if (L > R || R < pos || L > pos) return;
  if (L == R) {
    Arb[val][K] = Left[val][K] = Right[val][K] = v;
    return;
  }
  Update(val, K * 2, L, (L + R) / 2, pos, v);
  Update(val, K * 2 + 1, (L + R) / 2 + 1, R, pos, v);
  Arb[val][K] = max(Arb[val][K * 2], Arb[val][K * 2 + 1]);
  Arb[val][K] = max(Arb[val][K], Right[val][K * 2] + Left[val][K * 2 + 1]);
  if (Left[val][K * 2] == (L + R) / 2 - L + 1)
    Left[val][K] = Left[val][K * 2] + Left[val][K * 2 + 1];
  else
    Left[val][K] = Left[val][K * 2];
  if (Right[val][K * 2 + 1] == R - (L + R) / 2)
    Right[val][K] = Right[val][K * 2] + Right[val][K * 2 + 1];
  else
    Right[val][K] = Right[val][K * 2 + 1];
}
void Update2(int K, int L, int R, int pos, int val) {
  if (L > R || L > pos || R < pos) return;
  if (L == R) {
    Arb2[K] = val;
    return;
  }
  if (pos > (L + R) / 2)
    Update2(K * 2 + 1, (L + R) / 2 + 1, R, pos, val);
  else
    Update2(K * 2, L, (L + R) / 2, pos, val);
  Arb2[K] = max(Arb2[K * 2], Arb2[K * 2 + 1]);
}
int Query2(int K, int L, int R, int x, int y) {
  if (L > R || L > y || R < x) return 0;
  if (L >= x && R <= y) return Arb2[K];
  int a = Query2(K * 2, L, (L + R) / 2, x, y);
  int b = Query2(K * 2 + 1, (L + R) / 2 + 1, R, x, y);
  return max(a, b);
}
void Query(int val, int K, int L, int R, int x, int y) {
  if (L > R || L > y || R < x) {
    return;
  }
  if (L >= x && R <= y) {
    ans = max(ans, Arb[val][K]);
    ans = max(ans, Right2 + Left[val][K]);
    if (Right[val][K] == R - L + 1)
      Right2 += Right[val][K];
    else
      Right2 = Right[val][K];
    return;
  }
  Query(val, K * 2, L, (L + R) / 2, x, y);
  Query(val, K * 2 + 1, (L + R) / 2 + 1, R, x, y);
}
void Upd() {
  int pos;
  scanf("%d ", &pos);
  scanf("%s", Str);
  S[pos].clear();
  S[pos] += Str;
  if (pos > 1) {
    if (X[pos - 1] > limit) P.erase(pos - 1);
    X[pos - 1] = LCP(pos - 1, pos);
    if (X[pos - 1] > limit) P.insert(pos - 1);
    int l = min(X[pos - 1], limit);
    for (int i = 1; i <= l; i++) {
      Update(i, 1, 1, N - 1, pos - 1, 1);
    }
    for (int i = X[pos - 1] + 1; i <= limit; i++)
      Update(i, 1, 1, N - 1, pos - 1, 0);
  }
  if (pos < N) {
    if (X[pos] > limit) P.erase(pos);
    X[pos] = LCP(pos, pos + 1);
    if (X[pos] > limit) P.insert(pos);
    int l = min(X[pos], limit);
    for (int i = 1; i <= l; i++) {
      Update(i, 1, 1, N - 1, pos, 1);
    }
    for (int i = X[pos] + 1; i <= limit; i++) Update(i, 1, 1, N - 1, pos, 0);
  }
  Update2(1, 1, N, pos, S[pos].size());
}
void Qu(int left, int right) {
  long long res = 0;
  if (N == 1) {
    res = max(res, 1LL * Query2(1, 1, N, left, right));
    printf("%I64d\n", res);
    return;
  }
  for (int i = 1; i <= limit; i++) {
    ans = Right2 = 0;
    if (left < right) Query(i, 1, 1, N - 1, left, right - 1);
    if (ans > 0) res = max(res, 1LL * i * (ans + 1));
  }
  res = max(res, 1LL * Query2(1, 1, N, left, right));
  auto it = P.lower_bound(left);
  int cnt = 0;
  if (it != P.end() && *it < right) {
    Aux[++cnt] = X[*it];
    it = next(it);
    for (; it != P.end(); it = next(it)) {
      if (*it >= right) break;
      if (*it - *prev(it) > 1) {
        Aux[++cnt] = 0;
      }
      Aux[++cnt] = X[*it];
    }
    for (int j = 1; j <= cnt; j++) Next[j] = cnt + 1, Prev[j] = 0;
    int top = 0;
    for (int j = 1; j <= cnt; j++) {
      while (top > 0 && Aux[j] < Aux[Stack[top]]) {
        Next[Stack[top]] = j;
        --top;
      }
      Stack[++top] = j;
    }
    top = 0;
    for (int j = cnt; j >= 1; j--) {
      while (top > 0 && Aux[j] < Aux[Stack[top]]) {
        Prev[Stack[top]] = j;
        --top;
      }
      Stack[++top] = j;
    }
    for (int j = 1; j <= cnt; j++) {
      res = max(res, 1LL * Aux[j] * (Next[j] - Prev[j]));
    }
  }
  printf("%I64d\n", res);
}
int main() {
  Read();
  buildX();
  if (N > 1) {
    for (int i = 1; i <= limit; i++) buildTree(i, 1, 1, N - 1);
  }
  buildTree2(1, 1, N);
  for (int i = 1; i <= Q; i++) {
    int type;
    scanf("%d", &type);
    if (type == 2)
      Upd();
    else {
      int l, r;
      scanf("%d%d", &l, &r);
      Qu(l, r);
    }
  }
  return 0;
}