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;
function<void(void)> ____ = []() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
};
const int MAXN = 3e5 + 7;
struct AhoCorasick {
  int tot, ch[MAXN][26], fail[MAXN];
  int newnode() {
    tot++;
    memset(ch[tot], 0, sizeof(ch[tot]));
    return tot;
  }
  AhoCorasick() {
    tot = -1;
    newnode();
  }
  int insert(char *s) {
    int u = 0;
    for (int i = 0; s[i]; i++) {
      int c = s[i] - 'a';
      if (!ch[u][c]) ch[u][c] = newnode();
      u = ch[u][c];
    }
    return u;
  }
  vector<int> G[MAXN];
  void buildFail() {
    queue<int> que;
    for (int c = 0; c < 26; c++) {
      int v = ch[0][c];
      if (!v) continue;
      que.push(v);
      fail[v] = 0;
    }
    while (!que.empty()) {
      int u = que.front();
      que.pop();
      for (int c = 0; c < 26; c++) {
        if (!ch[u][c]) {
          ch[u][c] = ch[fail[u]][c];
          continue;
        }
        que.push(ch[u][c]);
        int v = fail[u];
        while (v and !ch[v][c]) v = fail[v];
        fail[ch[u][c]] = ch[v][c];
      }
    }
    for (int i = 1; i <= tot; i++) G[fail[i]].push_back(i);
  }
} aho;
struct SegmentTree {
  int l[MAXN << 2], r[MAXN << 2], maxx[MAXN << 2];
  void build(int L, int R, int rt = 1) {
    l[rt] = L;
    r[rt] = R;
    maxx[rt] = -1;
    if (L + 1 == R) return;
    int mid = (L + R) >> 1;
    build(L, mid, rt << 1);
    build(mid, R, rt << 1 | 1);
  }
  void modify(int pos, int x, int rt = 1) {
    if (l[rt] + 1 == r[rt]) {
      maxx[rt] = x;
      return;
    }
    int mid = (l[rt] + r[rt]) >> 1;
    if (pos < mid)
      modify(pos, x, rt << 1);
    else
      modify(pos, x, rt << 1 | 1);
    maxx[rt] = max(maxx[rt << 1], maxx[rt << 1 | 1]);
  }
  int qmax(int L, int R, int rt = 1) {
    if (L >= r[rt] or l[rt] >= R) return -1;
    if (L <= l[rt] and r[rt] <= R) return maxx[rt];
    return max(qmax(L, R, rt << 1), qmax(L, R, rt << 1 | 1));
  }
} seg;
int idx, dfn[MAXN], top[MAXN], sz[MAXN], son[MAXN], dep[MAXN], par[MAXN];
void firstDfs(int u, int d, int fa) {
  sz[u] = 1;
  dep[u] = d;
  par[u] = fa;
  for (int v : aho.G[u]) {
    firstDfs(v, d + 1, u);
    if (!son[u] or sz[v] > sz[son[u]]) son[u] = v;
  }
}
void secondDfs(int u, int tp) {
  top[u] = tp;
  dfn[u] = ++idx;
  if (son[u]) secondDfs(son[u], tp);
  for (int v : aho.G[u]) {
    if (v == son[u]) continue;
    secondDfs(v, v);
  }
}
int n, m, trienode[MAXN];
set<pair<int, int> > S[MAXN];
char buf[MAXN];
int getmax(int u, int v = 0) {
  int ret = -1;
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]]) swap(u, v);
    ret = max(ret, seg.qmax(dfn[top[u]], dfn[u] + 1));
    u = par[top[u]];
  }
  if (dep[u] > dep[v]) swap(u, v);
  return max(ret, seg.qmax(dfn[u], dfn[v] + 1));
}
int w[MAXN];
void solve() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%s", buf);
    trienode[i] = aho.insert(buf);
  }
  aho.buildFail();
  firstDfs(0, 0, 0);
  secondDfs(0, 0);
  seg.build(1, MAXN);
  for (int i = 1; i <= n; i++) {
    S[dfn[trienode[i]]].insert(make_pair(0, i));
    seg.modify(dfn[trienode[i]], 0);
    w[i] = 0;
  }
  for (int kase = 1; kase <= m; kase++) {
    int op;
    scanf("%d", &op);
    if (op == 1) {
      int id, x;
      scanf("%d %d", &id, &x);
      S[dfn[trienode[id]]].erase(make_pair(w[id], id));
      w[id] = x;
      S[dfn[trienode[id]]].insert(make_pair(w[id], id));
      seg.modify(dfn[trienode[id]], S[dfn[trienode[id]]].rbegin()->first);
    } else {
      scanf("%s", buf);
      int u = 0, ret = -1;
      for (int i = 0; buf[i]; i++) {
        int c = buf[i] - 'a';
        u = aho.ch[u][c];
        ret = max(ret, getmax(u));
      }
      cout << ret << endl;
    }
  }
}
int main() {
  solve();
  return 0;
}