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 MAXN = 100005;
struct RMQTree {
  int n, tree[MAXN * 4];
  void init(int tn) { n = tn; }
  void update(int l, int r, int p, int v, int id) {
    if (l == r) {
      tree[id] = v;
      return;
    }
    int m = (l + r) / 2, lc = id * 2, rc = id * 2 + 1;
    if (p <= m)
      update(l, m, p, v, lc);
    else
      update(m + 1, r, p, v, rc);
    tree[id] = max(tree[lc], tree[rc]);
  }
  int query(int l, int r, int ql, int qr, int id) {
    if (r < ql or qr < l) return -MAXN;
    if (ql <= l and r <= qr) return tree[id];
    int m = (l + r) / 2, lc = id * 2, rc = id * 2 + 1;
    return max(query(l, m, ql, qr, lc), query(m + 1, r, ql, qr, rc));
  }
  void upd(int x, int v) { update(1, n, x, v, 1); }
  int qry(int l, int r) { return query(1, n, l, r, 1); }
} rmqtree;
struct SegmentTree {
  struct Node {
    int prv, suf, ans, all;
    Node() { prv = suf = ans = all = 0; }
  } tree[MAXN * 4];
  int n;
  void init(int tn) {
    n = tn;
    for (int i = 0; i < (n * 4); i++) tree[i] = Node();
  }
  Node merge(const Node &lc, const Node &rc) {
    Node nd;
    nd.ans = max(lc.ans, rc.ans);
    nd.ans = max(nd.ans, lc.suf + rc.prv);
    nd.prv = lc.prv;
    if (lc.all) nd.prv += rc.prv;
    nd.suf = rc.suf;
    if (rc.all) nd.suf += lc.suf;
    if (lc.all and rc.all) nd.all = 1;
    return nd;
  }
  void update(int l, int r, int x, int v, int id) {
    if (l == r) {
      tree[id].prv = tree[id].suf = tree[id].ans = tree[id].all = v;
      return;
    }
    int m = (l + r) / 2, lc = id * 2, rc = id * 2 + 1;
    if (x <= m)
      update(l, m, x, v, lc);
    else
      update(m + 1, r, x, v, rc);
    tree[id] = merge(tree[lc], tree[rc]);
  }
  Node query(int l, int r, int ql, int qr, int id) {
    if (l == ql and r == qr) return tree[id];
    int m = (l + r) / 2, lc = id * 2, rc = id * 2 + 1;
    if (qr <= m) return query(l, m, ql, qr, lc);
    if (m < ql) return query(m + 1, r, ql, qr, rc);
    Node a = query(l, m, ql, m, lc);
    Node b = query(m + 1, r, m + 1, qr, rc);
    return merge(a, b);
  }
  void upd(int x, int v) { update(1, n, x, v, 1); }
  int qry(int l, int r) {
    if (l > r) return 0;
    return query(1, n, l, r, 1).ans;
  }
} tree;
struct Operation {
  int cmd, a, b;
  vector<pair<int, int> > event;
  void add_event(int x, int v) { event.emplace_back(x, v); }
} op[MAXN];
int N, Q, A[MAXN];
long long sol[MAXN];
string ip[MAXN], second[MAXN];
vector<int> plen;
int lcp(const string &s1, const string &s2) {
  int len = min(((int)((s1).size())), ((int)((s2).size())));
  for (int i = 0; i < (len); i++) {
    if (s1[i] != s2[i]) return i;
  }
  return len;
}
int lcp(int l, int r) {
  if (l == r) return ((int)((second[l]).size()));
  int res = MAXN;
  for (int i = (l); i <= (r - 1); i++) {
    res = min(res, lcp(second[i], second[i + 1]));
  }
  return res;
}
long long slow(int a, int b) {
  long long res = 0;
  for (int l = (a); l <= (b); l++) {
    for (int r = (l); r <= (b); r++) {
      long long tmp = 1LL * (r - l + 1) * lcp(l, r);
      res = max(res, tmp);
    }
  }
  return res;
}
void input() {
  cin >> N >> Q;
  rmqtree.init(N);
  for (int i = (1); i <= (N); i++) {
    cin >> ip[i];
    second[i] = ip[i];
    rmqtree.upd(i, ((int)((ip[i]).size())));
  }
  for (int i = (1); i <= (N - 1); i++) {
    A[i] = lcp(second[i], second[i + 1]);
    plen.push_back(A[i]);
  }
  for (int i = 0; i < (Q); i++) {
    cin >> op[i].cmd;
    if (op[i].cmd == 1) {
      cin >> op[i].a >> op[i].b;
      sol[i] = rmqtree.qry(op[i].a, op[i].b);
    } else {
      int id;
      string s;
      cin >> id >> s;
      rmqtree.upd(id, ((int)((s).size())));
      second[id] = s;
      if (id > 1) {
        op[i].add_event(id - 1, lcp(second[id - 1], second[id]));
      }
      if (id < N) {
        op[i].add_event(id, lcp(second[id], second[id + 1]));
      }
      for (auto it : op[i].event) plen.push_back(it.second);
    }
  }
}
void solve() {
  sort(begin(plen), end(plen));
  plen.resize(unique(begin(plen), end(plen)) - begin(plen));
  ;
  for (auto lb : plen) {
    for (int i = (1); i <= (N); i++) second[i] = ip[i];
    tree.init(N);
    for (int i = (1); i <= (N - 1); i++) {
      A[i] = lcp(second[i], second[i + 1]);
      if (A[i] >= lb)
        tree.upd(i, 1);
      else
        tree.upd(i, 0);
    }
    for (int i = 0; i < (Q); i++) {
      if (op[i].cmd == 1) {
        int width = tree.qry(op[i].a, op[i].b - 1);
        if (!width) continue;
        width++;
        sol[i] = max(sol[i], 1LL * lb * width);
      } else {
        for (auto it : op[i].event) {
          int x = it.first, v = it.second;
          A[x] = v;
          if (v >= lb)
            tree.upd(x, 1);
          else
            tree.upd(x, 0);
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  input();
  solve();
  for (int i = 0; i < (Q); i++) {
    if (op[i].cmd == 1) {
      cout << sol[i] << endl;
    }
  }
  return 0;
}