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;
template <typename T = int>
struct Max {
  T val;
  const T nut = numeric_limits<T>::min();
  Max() { val = nut; }
  Max(const T& _val) { val = _val; }
  void operator=(const Max& o) { val = o.val; }
  Max operator+(const Max& o) const { return val > o.val ? val : o.val; }
};
template <typename T = long long>
struct subl {
  T mx, ml, ps, pl, ss, sl, sm, ln;
  subl() {
    mx = 0;
    ml = 0;
    ps = 0;
    pl = 0;
    ss = 0;
    sl = 0;
    sm = 0;
    ln = 0;
  }
  subl(const T& v) {
    mx = v;
    ml = 1;
    ps = v;
    pl = 1;
    ss = v;
    sl = 1;
    sm = v;
    ln = 1;
  }
  subl(T _mx, T _ml, T _ps, T _pl, T _ss, T _sl, T _sm, T _ln) {
    mx = _mx;
    ml = _ml;
    ps = _ps;
    pl = _pl;
    ss = _ss;
    sl = _sl;
    sm = _sm;
    ln = _ln;
  }
  void operator=(const subl& o) {
    mx = o.mx;
    ml = o.ml;
    ps = o.ps;
    pl = o.pl;
    ss = o.ss;
    sl = o.sl;
    sm = o.sm;
    ln = o.ln;
  }
  subl operator+(const subl& o) const {
    return subl(
        max({mx, o.mx, ss + o.ps}),
        max({pair<T, T>(ss + o.ps, sl + o.pl), pair<T, T>(mx, ml),
             pair<T, T>(o.mx, o.ml)})
            .second,
        max(ps, sm + o.ps),
        max(pair<T, T>(ps, pl), pair<T, T>(sm + o.ps, ln + o.pl)).second,
        max(ss + o.sm, o.ss),
        max(pair<T, T>(o.ss, o.sl), pair<T, T>(ss + o.sm, sl + o.ln)).second,
        sm + o.sm, ln + o.ln);
  }
};
template <typename T, typename T2 = int>
class segtree {
 private:
  int b;
  vector<T> tr;

 public:
  segtree() {}
  segtree(int n) {
    b = 1;
    while (b < n) {
      b <<= 1;
    }
    tr.assign(2 * b, T());
  }
  segtree(const vector<T2>& arr) {
    b = 1;
    while (b < (int)arr.size()) {
      b <<= 1;
    }
    tr.assign(2 * b, T());
    for (int i = 0; i < (int)arr.size(); i++) {
      tr[i + b] = T(arr[i]);
    }
    for (int i = b - 1; i > 0; i--) {
      tr[i] = tr[i << 1] + tr[i << 1 | 1];
    }
  }
  void upd(int i, const T2& val) {
    tr[i += b] = T(val);
    for (i >>= 1; i > 0; i >>= 1) {
      tr[i] = tr[i << 1] + tr[i << 1 | 1];
    }
  }
  T qry(int l, int r) {
    T ansl = T(), ansr = T();
    for (l += b, r += b; l <= r; l >>= 1, r >>= 1) {
      if (l & 1) ansl = ansl + tr[l++];
      if (!(r & 1)) ansr = tr[r--] + ansr;
    }
    return ansl + ansr;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  vector<string> s(n);
  vector<int> LN(n, 0);
  set<int> Vals;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    LN[i] = s[i].length();
  }
  auto LCP = [&](const string& ss, const string& t) {
    int ans = 0;
    for (int i = 0; i < (int)min(ss.length(), t.length()); i++) {
      if (ss[i] == t[i]) {
        ans++;
      } else {
        break;
      }
    }
    Vals.insert(ans);
    return ans;
  };
  vector<int> OP(q), L(q), R(q), res(q, 0), Lcp(n - 1, 0);
  vector<vector<pair<int, int>>> qc(q);
  for (int i = 1; i < n; i++) {
    Lcp[i - 1] = LCP(s[i - 1], s[i]);
  }
  for (int tt = 0; tt < q; tt++) {
    cin >> OP[tt];
    if (OP[tt] == 1) {
      cin >> L[tt] >> R[tt];
      --L[tt];
      --R[tt];
    } else {
      cin >> L[tt];
      --L[tt];
      cin >> s[L[tt]];
      R[tt] = s[L[tt]].length();
      if (L[tt] > 0) {
        qc[tt].emplace_back(L[tt] - 1, LCP(s[L[tt] - 1], s[L[tt]]));
      }
      if (L[tt] + 1 < n) {
        qc[tt].emplace_back(L[tt], LCP(s[L[tt]], s[L[tt] + 1]));
      }
    }
  }
  const int inf = 1e9;
  for (int mn : Vals) {
    vector<int> bad(n - 1);
    for (int i = 0; i < n - 1; i++) {
      bad[i] = (Lcp[i] >= mn ? 1 : -inf);
    }
    segtree<subl<long long>, int> st(bad);
    for (int tt = 0; tt < q; tt++) {
      if (OP[tt] == 1) {
        int a = L[tt], b = R[tt];
        int& ans = res[tt];
        if (a < b) {
          int z = st.qry(a, b - 1).ml;
          ans = max(ans, mn * (z + (z > 0)));
        }
      } else {
        for (const auto& p : qc[tt]) {
          st.upd(p.first, p.second >= mn ? 1 : -inf);
        }
      }
    }
  }
  segtree<Max<int>, int> lns(LN);
  for (int tt = 0; tt < q; tt++) {
    if (OP[tt] == 1) {
      cout << max(res[tt], lns.qry(L[tt], R[tt]).val) << '\n';
    } else {
      lns.upd(L[tt], R[tt]);
    }
  }
  return 0;
}