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) { return val > o.val ? val : o.val; }
};
int LB;
template <typename T2 = int>
struct Tp {
  using T = array<T2, 4>;
  T val;
  const T nut = {};
  Tp() { val = nut; }
  Tp(const T2& _val) {
    T2 X = (_val >= LB);
    val = {X, X, X, 1};
  }
  Tp(const T _val) { val = _val; }
  void operator=(const Tp& o) { val = o.val; }
  Tp operator+(const Tp& o) const {
    return Tp({max({val[0], o.val[0], val[2] + o.val[1]}),
               (val[1] == val[3]) * o.val[1] + val[1],
               (o.val[2] == o.val[3]) * val[2] + o.val[2], val[3] + o.val[3]});
  }
};
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]));
      }
    }
  }
  for (int mn : Vals) {
    LB = mn;
    segtree<Tp<int>, int> st(Lcp);
    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).val[0];
          ans = max(ans, mn * (z + (z > 0)));
        }
      } else {
        for (const auto& p : qc[tt]) {
          st.upd(p.first, p.second);
        }
      }
    }
  }
  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;
}