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;
inline void read(int &x) {
  register int c = getchar();
  x = 0;
  int neg = 0;
  for (; ((c < 48 || c > 57) && c != '-'); c = getchar())
    ;
  if (c == '-') {
    neg = 1;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x = -x;
}
inline void writeln(int x) {
  char buffor[21];
  register int i = 0;
  int neg = 0;
  if (x < 0) {
    neg = 1;
    x = -x;
  }
  do {
    buffor[i++] = (x % 10) + '0';
    x /= 10;
  } while (x);
  i--;
  if (neg) putchar('-');
  while (i >= 0) putchar(buffor[i--]);
  putchar('\n');
}
const int N = (int)1e5 + 10;
int n, q;
int lcp[N];
string str[N];
struct node {
  vector<pair<int, int> > Left, Right;
  int res;
};
int low[4 * N], high[4 * N];
node it[4 * N];
void input() {
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> str[i];
}
void cal(node a, node b, node &c, int lcp_ab) {
  if (a.res == -1) {
    c = b;
    return;
  } else if (b.res == -1) {
    c = a;
    return;
  };
  c.Left.clear();
  for (auto it : a.Left) c.Left.push_back(it);
  if (lcp_ab < c.Left.back().first) c.Left.push_back(pair<int, int>(lcp_ab, 0));
  for (auto it : b.Left)
    if (it.first >= c.Left.back().first)
      c.Left.back().second += it.second;
    else
      c.Left.push_back(pair<int, int>(it.first, it.second));
  c.Right.clear();
  for (auto it : b.Right) c.Right.push_back(it);
  if (lcp_ab < c.Right.back().first)
    c.Right.push_back(pair<int, int>(lcp_ab, 0));
  for (auto it : a.Right)
    if (it.first >= c.Right.back().first)
      c.Right.back().second += it.second;
    else
      c.Right.push_back(pair<int, int>(it.first, it.second));
  c.res = max(a.res, b.res);
  int i, j, sza, szb, sum = 0, len = lcp_ab;
  i = 0;
  j = 0;
  sza = a.Right.size();
  szb = b.Left.size();
  while (i < sza or j < szb) {
    if (j == szb) {
      sum += a.Right[i].second;
      if (a.Right[i].first < len) len = a.Right[i].first;
      i++;
    } else if (i == sza) {
      sum += b.Left[j].second;
      if (b.Left[j].first < len) len = b.Left[j].first;
      j++;
    } else {
      if (a.Right[i].first >= b.Left[j].first) {
        sum += a.Right[i].second;
        if (a.Right[i].first < len) len = a.Right[i].first;
        i++;
      } else {
        sum += b.Left[j].second;
        if (b.Left[j].first < len) len = b.Left[j].first;
        j++;
      }
    }
    c.res = max(c.res, len * sum);
  }
}
void build(int x, int l, int r) {
  low[x] = l;
  high[x] = r;
  if (l == r) {
    int sz = str[l].size();
    it[x].Left.push_back(pair<int, int>(sz, 1));
    it[x].Right.push_back(pair<int, int>(sz, 1));
    it[x].res = sz;
    return;
  };
  int m = (l + r) / 2;
  build(2 * x, l, m);
  build(2 * x + 1, m + 1, r);
  cal(it[2 * x], it[2 * x + 1], it[x], lcp[m]);
}
void update(int x, int pos, int sz) {
  if (low[x] == high[x]) {
    it[x].Left.back().first = sz;
    it[x].Right.back().first = sz;
    it[x].res = sz;
    return;
  }
  if (pos <= high[2 * x])
    update(2 * x, pos, sz);
  else
    update(2 * x + 1, pos, sz);
  cal(it[2 * x], it[2 * x + 1], it[x], lcp[high[2 * x]]);
}
node query(int x, int l, int r) {
  if (low[x] > r or high[x] < l) {
    node trash;
    trash.res = -1;
    return trash;
  }
  if (low[x] >= l and high[x] <= r) return it[x];
  node ans;
  cal(query(2 * x, l, r), query(2 * x + 1, l, r), ans, lcp[high[2 * x]]);
  return ans;
}
void init() {
  for (int i = 1; i <= n - 1; i++) {
    int sz = min(str[i].size(), str[i + 1].size());
    lcp[i] = 0;
    for (int p = 0; p <= sz - 1; p++)
      if (str[i][p] == str[i + 1][p])
        lcp[i] = p + 1;
      else
        break;
  }
  build(1, 1, n);
}
void solve() {
  init();
  for (int i = 1; i <= q; i++) {
    int typ;
    cin >> typ;
    if (typ == 1) {
      int a, b;
      cin >> a >> b;
      cout << query(1, a, b).res << '\n';
    } else {
      int x;
      cin >> x;
      cin >> str[x];
      int sz = str[x].size();
      if (x != 1) {
        lcp[x - 1] = 0;
        for (int p = 0; p <= sz - 1; p++)
          if (str[x - 1][p] == str[x][p])
            lcp[x - 1] = p + 1;
          else
            break;
      };
      if (x != n) {
        lcp[x] = 0;
        for (int p = 0; p <= sz - 1; p++)
          if (str[x][p] == str[x + 1][p])
            lcp[x] = p + 1;
          else
            break;
      };
      update(1, x, sz);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  input();
  solve();
  return 0;
}