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>
void init();
void solve();
int main() {
  init();
  while (scanf("%*[ \t\n]*") != EOF) {
    solve();
  }
  return 0;
}
namespace lct {
struct node_t {
  node_t *c[2], *p;
  int key, s;
  bool rev;
} memo[300005], *nil, *pt[300005], *st[300005];
void init(node_t *x) {
  x->c[0] = x->c[1] = x->p = nil;
  x->key = x->s = -1;
  x->rev = false;
}
void init(int n) {
  pt[0] = nil = &memo[0];
  init(nil);
  for (int i = 1; i <= n; i++) {
    pt[i] = &memo[i];
    init(pt[i]);
  }
}
void update(node_t *x) {
  if (x == nil) {
    return;
  }
  x->s = std::max(std::max(x->c[0]->s, x->key), x->c[1]->s);
}
void rotate(node_t *x, int f) {
  node_t *y = x->p, *z = y->p;
  x->p = z, y->p = x;
  if (z != nil) {
    if (y == z->c[0]) {
      z->c[0] = x;
    } else if (y == z->c[1]) {
      z->c[1] = x;
    }
  }
  y->c[f ^ 1] = x->c[f];
  if (y->c[f ^ 1] != nil) {
    y->c[f ^ 1]->p = y;
  }
  x->c[f] = y;
  update(y);
  update(x);
}
bool isroot(node_t *x) {
  return x->p == nil || (x->p->c[0] != x && x->p->c[1] != x);
}
void reverse(node_t *x) {
  if (x != nil) {
    std::swap(x->c[0], x->c[1]);
    x->rev ^= 1;
  }
}
void pushdown(node_t *x) {
  if (x == nil) {
    return;
  }
  if (x->rev) {
    reverse(x->c[0]);
    reverse(x->c[1]);
    x->rev = false;
  }
}
void splay(node_t *x) {
  int top = 1;
  st[0] = x;
  for (node_t *q = x; !isroot(q);) {
    st[top++] = (q = q->p);
  }
  while (top) {
    pushdown(st[--top]);
  }
  while (!isroot(x)) {
    node_t *y = x->p;
    if (isroot(y)) {
      rotate(x, y->c[0] == x);
    } else {
      int t = (y == y->p->c[0]);
      if (x == y->c[t]) {
        rotate(x, t ^ 1);
        rotate(x, t);
      } else {
        rotate(y, t);
        rotate(x, t);
      }
    }
  }
}
node_t *expose(node_t *x) {
  node_t *y;
  for (y = nil; x != nil; x = x->p) {
    splay(x);
    x->c[1] = y;
    update(y = x);
  }
  return y;
}
void set(node_t *x, int v) {
  x->key = v;
  splay(x);
}
node_t *head(node_t *x) {
  if (x == nil) {
    return nil;
  }
  while (x->c[0] != nil) {
    pushdown(x);
    x = x->c[0];
  }
  splay(x);
  return x;
}
node_t *getRoot(node_t *x) { return head(expose(x)); }
void tackle(node_t *first, node_t *second);
void query(node_t *x, node_t *y) {
  node_t *ry = head(expose(y)), *rx = head(expose(x));
  if (rx != ry) {
  } else {
    for (node_t *u = y, *v = nil; u != nil; u = u->p) {
      splay(u);
      if (u->p == nil) {
        tackle(v, u);
        return;
      }
      u->c[1] = v;
      update(v = u);
    }
  }
}
void setRoot(node_t *x) { reverse(expose(x)); }
bool merge(node_t *x, node_t *y) {
  node_t *ry = head(expose(y)), *rx = head(expose(x));
  if (rx == ry) {
    return false;
  } else {
    setRoot(x);
    splay(x), x->p = y;
    return true;
  }
}
void cut(node_t *x) {
  splay(x);
  if (x->c[0] != nil)
    x->c[0]->p = x->p, x->p = x->c[0] = nil;
  else
    x->p = nil;
}
node_t *lca(node_t *x, node_t *y) {
  node_t *rx = head(expose(x));
  node_t *ey = expose(y), *ry = head(ey);
  if (rx == ry)
    return ey;
  else
    return nil;
}
};  // namespace lct
namespace trie {
struct node_t {
  ;
  node_t *next[26];
  node_t *fail;
} memo[300005], *root, *cur;
node_t *new_node() {
  std::fill(cur->next, cur->next + 26, root);
  cur->fail = root;
  return cur++;
}
void init() {
  cur = root = memo;
  root = new_node();
}
node_t *add(const char *s) {
  node_t *now = root;
  for (const char *p = s; *p; p++) {
    int c = *p - 'a';
    if (now->next[c] == root) {
      now->next[c] = new_node();
    }
    now = now->next[c];
  }
  return now;
}
node_t *queue[300005];
int bfs() {
  int f = 0, b = 0;
  root->fail = root;
  queue[b++] = root;
  while (f < b) {
    node_t *u = queue[f++];
    for (int i = 0; i < 26; i++) {
      node_t *v = u->next[i];
      if (v != root) {
        if (u != root) {
          v->fail = u->fail->next[i];
        }
        queue[b++] = v;
      } else {
        u->next[i] = u->fail->next[i];
      }
    }
  }
  return b;
}
};  // namespace trie
int res;
namespace lct {
void tackle(node_t *first, node_t *second) {
  res = std::max(res, first->s);
  res = std::max(res, second->key);
  res = std::max(res, second->c[1]->s);
}
}  // namespace lct
std::multiset<std::pair<int, int>> set;
int nid[300005], value[300005];
char s[300005];
void init() {}
int n, m;
void read() {
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    trie::node_t *target = trie::add(s);
    nid[i + 1] = target - trie::memo + 1;
  }
}
void solve() {
  scanf("%d%d", &n, &m);
  trie::init();
  read();
  int queue_size = trie::bfs();
  lct::init(trie::cur - trie::memo);
  set.clear();
  for (int i = 1; i <= n; i++) {
    lct::set(lct::pt[nid[i]], 0);
    set.insert({nid[i], 0});
    value[i] = 0;
  }
  for (int i = queue_size - 1; i > 0; i--) {
    lct::merge(lct::pt[trie::queue[i] - trie::memo + 1],
               lct::pt[trie::queue[i]->fail - trie::memo + 1]);
  }
  int op, id, v;
  for (int i = 0; i < m; i++) {
    scanf("%d", &op);
    if (op == 2) {
      scanf("%s", s);
      res = -1;
      trie::node_t *now = trie::root;
      for (const char *p = s; *p; p++) {
        int c = *p - 'a';
        now = now->next[c];
        lct::query(lct::pt[now - trie::memo + 1], lct::pt[1]);
      }
      printf("%d\n", res);
    } else {
      scanf("%d%d", &id, &v);
      set.erase(set.find({nid[id], value[id]}));
      value[id] = v;
      set.insert({nid[id], v});
      auto ub = set.lower_bound({nid[id] + 1, 0});
      ub--;
      lct::set(lct::pt[nid[id]], ub->second);
    }
  }
}