Problem: For the simplicity, let's say that the "Death Note" is a notebook that kills a person when their name is written in it.

It's easy to kill with it, but it's pretty hard to keep track of people you haven't killed and still plan to. You decided to make a "Death Database Management System" — a computer program that provides the easy access to the database of possible victims. Let me describe its specifications to you.

Let's define a victim entity: a victim has a name (not necessarily unique) that consists only of lowercase Latin letters and an integer suspicion value.

At the start of the program the user enters a list of n victim names into a database, each suspicion value is set to 0.

Then the user makes queries of two types: 

  * 1~i~x — set the suspicion value of the i-th victim to x; 
  * 2~q — given a string q find the maximum suspicion value of a victim whose name is a contiguous substring of q. 



Just to remind you, this program doesn't kill people, it only helps to search for the names to write down in an actual notebook. Thus, the list of the victims in the database doesn't change throughout the queries.

What are you waiting for? Write that program now!

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 3 ⋅ 10^5) — the number of victims and the number of queries, respectively.

Each of the next n lines contains a single string s_i — the name of the i-th victim. Each name consists only of lowercase Latin letters.

Each of the next m lines contains a query of one of two types: 

  * 1~i~x (1 ≤ i ≤ n, 0 ≤ x ≤ 10^9) — change the suspicion value of the i-th victim to x; 
  * 2~q — given a string q consisting only of lowercase Latin letters find the maximum suspicion value of a victim whose name is a contiguous substring of q. 



There is at least one query of the second type. The total length of the strings s_i doesn't exceed 3 ⋅ 10^5. The total length of the strings q doesn't exceed 3 ⋅ 10^5. 

Output

For each query of the second type print an integer value. If there is no victim name that is a contiguous substring of q, then print -1. Otherwise, print the maximum suspicion value of a victim whose name is a contiguous substring of q.

Examples

Input


5 8
kurou
takuo
takeshi
naomi
shingo
2 nakiraomi
2 abanaomicaba
1 3 943
2 takuotakeshishingo
1 5 135832
2 shingotakeshi
1 5 0
2 shingotakeshi


Output


-1
0
943
135832
943


Input


6 15
a
ab
ba
b
a
ba
2 aa
1 4 4
2 bbb
1 2 1
1 2 18
2 b
2 c
1 6 10
2 aba
2 abbbba
1 2 12
2 bbaaab
1 1 11
1 5 5
2 baa


Output


0
4
4
-1
18
18
12
11

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 714514;
char c[N];
vector<int> v[N];
int d[N], fa[N], sz[N], tp[N], id[N], s[N];
int tr[N][26], fl[N], e[N], w[N];
int n, m, tot, cnt, tt[N << 2];
multiset<int> st[N];
void add(int i, int l, int r, int s, int w) {
  if (l == r) {
    tt[i] = w;
    return;
  }
  if (s <= ((l + r) >> 1))
    add((i << 1), l, ((l + r) >> 1), s, w);
  else
    add((i << 1 | 1), ((l + r) >> 1) + 1, r, s, w);
  tt[i] = max(tt[(i << 1)], tt[(i << 1 | 1)]);
}
int query(int i, int l, int r, int s, int t) {
  if (s <= l && r <= t) return tt[i];
  int ans = -1;
  if (s <= ((l + r) >> 1)) ans = query((i << 1), l, ((l + r) >> 1), s, t);
  if (t > ((l + r) >> 1))
    ans = max(ans, query((i << 1 | 1), ((l + r) >> 1) + 1, r, s, t));
  return ans;
}
int que(int x) {
  int ans = -1;
  while (tp[x])
    ans = max(query(1, 1, tot + 1, id[tp[x]], id[x]), ans), x = fa[tp[x]];
  ans = max(query(1, 1, tot + 1, 1, id[x]), ans);
  return ans;
  ;
}
int qry() {
  int l = strlen(c), x = 0, kkr = -1;
  for (int i = 0, t; i < l; i++) {
    t = c[i] - 'a';
    x = tr[x][t];
    kkr = max(kkr, que(x));
  }
  return kkr;
}
void dfs1(int x, int f) {
  d[x] = d[f] + 1;
  fa[x] = f;
  sz[x] = 1;
  s[x] = 514514;
  for (int i = 0, to; i < v[x].size(); i++) {
    to = v[x][i];
    if (to == f) continue;
    dfs1(to, x);
    sz[x] += sz[to];
    if (sz[to] > sz[s[x]]) s[x] = to;
  }
}
void dfs2(int x, int tf) {
  id[x] = ++cnt;
  tp[x] = tf;
  if (s[x] == 514514) return;
  dfs2(s[x], tf);
  for (int i = 0, to; i < v[x].size(); i++) {
    to = v[x][i];
    if (to != fa[x] && to != s[x]) dfs2(to, to);
  }
}
void make(int j) {
  int l = strlen(c), x = 0;
  for (int i = 0, t; i < l; i++) {
    t = c[i] - 'a';
    if (!tr[x][t]) tr[x][t] = ++tot;
    x = tr[x][t];
  }
  e[j] = x;
}
void get() {
  queue<int> q;
  for (int i = 0; i <= 25; i++)
    if (tr[0][i]) q.push(tr[0][i]);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = 0; i <= 25; i++) {
      if (tr[x][i])
        fl[tr[x][i]] = tr[fl[x]][i], q.push(tr[x][i]);
      else
        tr[x][i] = tr[fl[x]][i];
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  memset(tt, -1, sizeof(tt));
  for (int i = 1; i <= n; i++) scanf("%s", c), make(i);
  get();
  for (int i = 1; i <= tot; i++) v[fl[i]].push_back(i);
  dfs1(0, 0);
  dfs2(0, 0);
  for (int i = 1; i <= n; i++)
    add(1, 1, tot + 1, id[e[i]], 0), st[e[i]].insert(0);
  for (int i = 1, op, x, y; i <= m; i++) {
    scanf("%d", &op);
    if (op == 1) {
      scanf("%d%d", &x, &y);
      int u = e[x];
      st[u].erase(st[u].lower_bound(w[x]));
      st[u].insert(y);
      w[x] = y;
      add(1, 1, tot + 1, id[e[x]], *st[u].rbegin());
    }
    if (op == 2) scanf("%s", c), printf("%d\n", qry());
  }
}