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 N = 1e5 + 5;
const int S = 80;
int n, m, a[N];
string s[N];
struct item {
  int sum, suf[S + 1], pref[S + 1], ans;
  item(int x) {
    x = min(x, S);
    for (int i = 0; i <= S; i++) {
      suf[i] = pref[i] = (i <= x);
    }
    ans = x;
    sum = 1;
  }
  item() {
    ans = sum = 0;
    memset(suf, 0, sizeof(suf));
    memset(pref, 0, sizeof(pref));
  }
};
item t[4 * N];
inline item mrg(item a, item b) {
  item c;
  c.ans = max(a.ans, b.ans);
  c.sum = a.sum + b.sum;
  for (int i = 0; i <= S; i++) {
    c.pref[i] = a.pref[i];
    if (a.pref[i] == a.sum) {
      c.pref[i] += b.pref[i];
    }
    c.suf[i] = b.suf[i];
    if (b.suf[i] == b.sum) {
      c.suf[i] += a.suf[i];
    }
    if (a.suf[i] > 0 || b.pref[i] > 0) {
      c.ans = max(c.ans, i * (a.suf[i] + b.pref[i] + 1));
    }
  }
  return c;
}
void update(int v, int l, int r, int pos, int val) {
  if (l == r) {
    t[v] = item(val);
    return;
  }
  int mid = (r + l) >> 1;
  if (pos <= mid) {
    update(v + v, l, mid, pos, val);
  } else {
    update(v + v + 1, mid + 1, r, pos, val);
  }
  t[v] = mrg(t[v + v], t[v + v + 1]);
}
item get(int v, int l, int r, int tl, int tr) {
  if (l > r || l > tr || tl > r) {
    return item();
  }
  if (tl <= l && r <= tr) {
    return t[v];
  }
  int mid = (r + l) >> 1;
  return mrg(get(v + v, l, mid, tl, tr), get(v + v + 1, mid + 1, r, tl, tr));
}
set<int> q;
int st[4 * N], le[4 * N], ri[4 * N];
inline int lcp(int x, int y) {
  int cur = 0;
  while (cur < (int)s[x].size() && cur < (int)s[y].size() &&
         s[x][cur] == s[y][cur]) {
    cur += 1;
  }
  return cur;
}
int f[4 * N];
int gett(int v, int l, int r, int tl, int tr) {
  if (l > r || l > tr || tl > r) {
    return 0;
  }
  if (tl <= l && r <= tr) {
    return f[v];
  }
  int mid = (r + l) >> 1;
  return max(gett(v + v, l, mid, tl, tr), gett(v + v + 1, mid + 1, r, tl, tr));
}
void upd(int v, int l, int r, int pos, int val) {
  if (l == r) {
    f[v] = val;
    return;
  }
  int mid = (r + l) >> 1;
  if (pos <= mid) {
    upd(v + v, l, mid, pos, val);
  } else {
    upd(v + v + 1, mid + 1, r, pos, val);
  }
  f[v] = max(f[v + v], f[v + v + 1]);
}
void add(int pos) {
  a[pos] = lcp(pos, pos + 1);
  update(1, 1, n, pos, a[pos]);
  if (a[pos] > S) {
    q.insert(pos);
  }
}
void del(int pos) { q.erase(pos); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    upd(1, 1, n, i, (int)s[i].size());
  }
  for (int i = 1; i + 1 <= n; i++) {
    add(i);
  }
  while (m--) {
    int t;
    cin >> t;
    if (t == 1) {
      int l, r;
      cin >> l >> r;
      if (l == r) {
        cout << (int)s[l].size() << "\n";
        continue;
      }
      int ans = max(get(1, 1, n, l, r - 1).ans, gett(1, 1, n, l, r));
      int prv = -1, sz = 0;
      for (auto it = q.lower_bound(l); it != q.lower_bound(r); it++) {
        if (*it - 1 != prv) {
          st[++sz] = 0;
        }
        prv = *it;
        st[++sz] = a[prv];
      }
      vector<int> z;
      st[0] = st[sz + 1] = -1e9;
      z.push_back(0);
      for (int i = 1; i <= sz; i++) {
        while (!z.empty() && st[z.back()] >= st[i]) {
          z.pop_back();
        }
        le[i] = z.back();
        z.push_back(i);
      }
      z.clear();
      z.push_back(sz + 1);
      for (int i = sz; i >= 1; i--) {
        while (!z.empty() && st[z.back()] >= st[i]) {
          z.pop_back();
        }
        ri[i] = z.back();
        ans = max(ans, (ri[i] - le[i]) * st[i]);
        z.push_back(i);
      }
      cout << ans << "\n";
    } else {
      int x;
      string y;
      cin >> x >> y;
      if (x - 1 >= 1) {
        del(x - 1);
      }
      if (x + 1 <= n) {
        del(x);
      }
      s[x] = y;
      upd(1, 1, n, x, (int)s[x].size());
      if (x - 1 >= 1) {
        add(x - 1);
      }
      if (x + 1 <= n) {
        add(x);
      }
    }
  }
}