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 JAVA):

Solution:
/**
 * Created by Aminul on 11/19/2020.
 */

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class CF1437G {
    public static void main(String[] args) throws Exception {
        FastReader in = new FastReader(System.in);
        PrintWriter pw = new PrintWriter(System.out);
       
        final int N = 26 * (int) 3e5 + 50;
        AhoCorasick ahoCorasick = new AhoCorasick(N);
        MultiTreeSet<Integer> set[] = new MultiTreeSet[N + 1];

        int n = in.nextInt(), q = in.nextInt();
        int index[] = new int[n + 1];
        int value[] = new int[n + 1];
        
        for (int i = 1; i <= n; i++) {
            char[] s = in.next().toCharArray();
            int id = ahoCorasick.add(s);
            index[i] = id;
            if (set[id] == null) set[id] = new MultiTreeSet<>();
            set[id].add(0);
        }
        
        ahoCorasick.buildFail();

        for (int i = 0; i < q; i++) {
            int op = in.nextInt();
            if (op == 1) {
                int id = in.nextInt(), val = in.nextInt();
                int acID = index[id];
                set[acID].remove(value[id]);
                set[acID].add(val);
                value[id] = val;
                ahoCorasick.setVal(acID, set[acID].last());
            } else {
                char[] s = in.next().toCharArray();
                pw.println(ahoCorasick.query(s));
            }
        }

        pw.close();
    }

    static class AhoCorasick {
        int n, alphabet = 26, idx;
        int trie[][], f[], Q[], last[], val[];
        int end[];

        AhoCorasick(int N) {
            n = N;
            trie = new int[n][];
            f = new int[n];
            end = new int[n];
            Q = new int[n];
            last = new int[n];
            val = new int[n];
            init();
        }

        void init() {
            trie[0] = new int[alphabet];
            idx = 1;
        }

        int get_id(char ch) {
            return ch - 'a';
        }

        void setVal(int id, int value) {
            val[id] = value;
        }

        int add(char[] s) {
            int u = 0;
            for (char p : s) {
                int c = get_id(p);
                if (trie[u][c] == 0) {
                    trie[idx] = new int[alphabet];
                    trie[u][c] = idx++;
                }
                u = trie[u][c];
            }
            end[u] = u;
            return u;
        }

        void buildFail() {
            f[0] = 0;
            int qe = 0, qs = 0;
            for (int c = 0; c < alphabet; ++c) {
                int u = trie[0][c];
                trie[0][c] = u;
                if (u != 0) {
                    f[u] = 0;
                    Q[qe++] = u;
                }
            }
            while (qs < qe) {
                int r = Q[qs++];
                for (int c = 0; c < alphabet; ++c) {
                    int u = trie[r][c];
                    if (u != 0) {
                        Q[qe++] = u;
                        f[u] = trie[f[r]][c];
                        trie[r][c] = trie[r][c];
                        if (end[f[trie[r][c]]] > 0) last[trie[r][c]] = f[trie[r][c]];
                        else last[trie[r][c]] = last[f[trie[r][c]]];
                    } else trie[r][c] = trie[f[r]][c];
                }
            }
        }

        int query(char[] s) {
            int matches = 0;
            int j = 0;
            int len = s.length;
            int res = -1;
            for (int i = 0; i < len; i++) {
                int c = get_id(s[i]);
                j = trie[j][c];
                int tmp = j;
                while (tmp > 0) {
                    if (end[tmp] > 0) {
                        res = max(res, val[tmp]);
                    }
                    tmp = last[tmp];
                }
            }
            return res;
        }
    }

    static class MultiTreeSet<T> {
        int size = 0;
        TreeMap<T, Integer> map = new TreeMap<>();

        void add(T x) {
            Integer v = map.get(x);
            if (v == null) map.put(x, 1);
            else map.put(x, v + 1);
            size++;
        }

        boolean contains(T x) {
            return map.containsKey(x);
        }

        void clear() {
            map.clear();
        }

        void remove(T x) {
            if(!map.containsKey(x)) return;
            size--;
            int v = 0;
            map.put(x, v = map.get(x) - 1);
            if (v == 0) map.remove(x);
        }

        T lower(T x) {
            return map.lowerKey(x);
        }

        T higher(T x) {
            return map.higherKey(x);
        }

        T ceiling(T x) {
            return map.ceilingKey(x);
        }

        T floor(T x) {
            return map.floorKey(x);
        }

        T first() {
            return map.firstKey();
        }

        T last() {
            return map.lastKey();
        }

        int size() {
            return size;
        }
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }

    static class FastReader {
        InputStream is;
        private byte[] inbuf = new byte[1024];
        private int lenbuf = 0, ptrbuf = 0;

        public FastReader(InputStream is) {
            this.is = is;
        }

        public int readByte() {
            if (lenbuf == -1) throw new InputMismatchException();
            if (ptrbuf >= lenbuf) {
                ptrbuf = 0;
                try {
                    lenbuf = is.read(inbuf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0) return -1;
            }
            return inbuf[ptrbuf++];
        }

        public boolean isSpaceChar(int c) {
            return !(c >= 33 && c <= 126);
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }

        public int skip() {
            int b;
            while ((b = readByte()) != -1 && isSpaceChar(b)) ;
            return b;
        }

        public String next() {
            int b = skip();
            StringBuilder sb = new StringBuilder();
            while (!(isSpaceChar(b))) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }


        public String nextLine() {
            int c = skip();
            StringBuilder sb = new StringBuilder();
            while (!isEndOfLine(c)) {
                sb.appendCodePoint(c);
                c = readByte();
            }
            return sb.toString();
        }

        public int nextInt() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            while (true) {
                if (b >= '0' && b <= '9') {
                    num = (num << 3) + (num << 1) + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

        public long nextLong() {
            long num = 0;
            int b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = (num << 3) + (num << 1) + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public char[] next(int n) {
            char[] buf = new char[n];
            int b = skip(), p = 0;
            while (p < n && !(isSpaceChar(b))) {
                buf[p++] = (char) b;
                b = readByte();
            }
            return n == p ? buf : Arrays.copyOf(buf, p);
        }

        public char readChar() {
            return (char) skip();
        }
    }
}