Problem: Whoso in ignorance draws near to them and hears the Sirens' voice, he nevermore returns.

Homer, Odyssey

In the times of Jason and the Argonauts, it was well known that sirens use the sound of their songs to lure sailors into their demise. Yet only a few knew that every time sirens call a sailor by his name, his will weakens, making him more vulnerable. 

For the purpose of this problem, both siren songs and names of the sailors will be represented as strings of lowercase English letters. The more times the sailor's name occurs as a contiguous substring of the song, the greater danger he is in.

Jason found out that sirens can sing one of the n+1 songs, which have the following structure: let s_i (0 ≤ i ≤ n) be the i-th song and t be a string of length n, then for every i < n: s_{i+1} = s_i t_i s_i. In other words i+1-st song is the concatenation of i-th song, i-th letter (0-indexed) of t and the i-th song. 

Fortunately, he also knows s_0 and t. Jason wonders how many times a sailor's name is mentioned in a particular song. Answer q queries: given the sailor's name (w) and the index of a song (i) output the number of occurrences of w in s_i as a substring. As this number can be quite large, output its remainder modulo 10^9+7.

Input

In the first line of input there are two integers n, q (  1 ≤ n, q ≤ 10^5) meaning that there are n+1 songs and q queries. In the next two lines strings s_0 and t follow (1 ≤ |s_0| ≤ 100, |t| = n). 

Next q lines describe the queries; each one contains an integer k ( 0 ≤ k ≤ n), the index of the song sung by the sirens, and a non-empty string w, which is the name of a sailor. All strings in this problem consist only of lowercase English letters, and the sum of lengths of sailors' names does not exceed 10^6.

Output

Output q lines, i-th of them should contain the remainder modulo 10^9+7 of the number of occurrences of w in s_k.

Examples

Input


3 3
aa
bcd
2 aba
3 ca
3 aa


Output


2
2
8


Input


4 5
aba
bbac
1 a
3 baca
3 ab
2 bab
4 aba


Output


4
0
14
6
28

Note

In the first example songs of the sirens are as follows: 

  * Song 0: aa
  * Song 1: aabaa
  * Song 2: aabaacaabaa
  * Song 3: aabaacaabaadaabaacaabaa

Solution (in JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.SplittableRandom;
import java.io.IOException;
import java.math.BigInteger;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskG solver = new TaskG();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskG {
        SplittableRandom random = new SplittableRandom(0);
        final int MAX_LENGTH = (int) 1e6;
        final int MOD1 = BigInteger.valueOf((int) 1e9 + random.nextInt(100)).nextProbablePrime().intValue();
        final int MOD2 = BigInteger.valueOf((int) 1e9 + random.nextInt(100)).nextProbablePrime().intValue();
        final long X1 = 1 + random.nextInt(MOD1 - 1);
        final long X2 = 1 + random.nextInt(MOD2 - 1);
        long[] pow1 = new long[MAX_LENGTH + 1];
        long[] pow2 = new long[MAX_LENGTH + 1];

        {
            pow1[0] = 1 % MOD1;
            for (int i = 1; i < pow1.length; i++) {
                pow1[i] = pow1[i - 1] * X1 % MOD1;
            }
            pow2[0] = 1 % MOD2;
            for (int i = 1; i < pow2.length; i++) {
                pow2[i] = pow2[i - 1] * X2 % MOD2;
            }
        }

        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            final int MOD = (int) (1e9 + 7);
            int n = in.nextInt();
            int numQueries = in.nextInt();
            char[] s0 = in.next().toCharArray();
            char[] t = in.next().toCharArray();

            int[][] occurencesOfLetterAsBranching = new int[26][n + 1];
            for (int c = 0; c < 26; c++) {
                int[] o = occurencesOfLetterAsBranching[c];
                for (int i = 1; i <= n; i++) {
                    o[i] = (2 * o[i - 1] + (t[i - 1] == (char) (c + 'a') ? 1 : 0)) % MOD;
                }
            }

            char[] big;
            {
                String cur = new String(s0);
                for (int level = 0; level < n; level++) {
                    cur = cur + t[level] + cur;
                    if (cur.length() >= MAX_LENGTH) {
                        break;
                    }
                }
                big = cur.toCharArray();
            }
            StringHasher bigH = new StringHasher(big);

            int[] p2 = new int[n + 1];
            p2[0] = 1;
            for (int i = 1; i < p2.length; i++) {
                p2[i] = p2[i - 1] + p2[i - 1];
                if (p2[i] >= MOD) {
                    p2[i] -= MOD;
                }
            }

            for (int query = 0; query < numQueries; query++) {
                int k = in.nextInt();
                char[] w = in.next().toCharArray();
                StringHasher h = new StringHasher(w);
                if (big.length < w.length) {
                    out.println(0);
                    continue;
                }

                int occInS0 = 0;
                for (int pos = 0; pos + w.length <= s0.length; pos++) {
                    if (bigH.get1(pos, pos + w.length - 1) != h.get1(0, w.length - 1)) {
                        continue;
                    }
                    if (bigH.get2(pos, pos + w.length - 1) != h.get2(0, w.length - 1)) {
                        continue;
                    }
                    ++occInS0;
                }

                // No branching.
                long ans = (long) p2[k] * occInS0 % MOD;

                // Branching letter in |t| is w[i].
                for (int i = 0; i < w.length; i++) {
                    boolean ok = true;
                    // Is the prefix w[0, i-1] a suffix of the big string?
                    ok = ok && (i == 0 || bigH.get1(big.length - i, big.length - 1) == h.get1(0, i - 1));
                    ok = ok && (i == 0 || bigH.get2(big.length - i, big.length - 1) == h.get2(0, i - 1));
                    // Is the suffix w[i+1, w.len-1] a prefix of the big string?
                    ok = ok && (i == w.length - 1 || bigH.get1(0, w.length - i - 2) == h.get1(i + 1, w.length - 1));
                    ok = ok && (i == w.length - 1 || bigH.get2(0, w.length - i - 2) == h.get2(i + 1, w.length - 1));
                    if (!ok) {
                        continue;
                    }

                    int lvl = 0;
                    int l = s0.length;
                    int need = Math.max(i, w.length - i - 1);
                    while (need > l) {
                        ++lvl;
                        l = 2 * l + 1;
                    }
                    int firstBranchingLevel = lvl + 1;
                    if (firstBranchingLevel > k) {
                        continue;
                    }

                    // Slow version.
//                for (int j = firstBranchingLevel; j <= k; j++) {
//                    if (t[j - 1] == w[i]) {
//                        ans = (ans + p2[k - j]) % MOD;
//                    }
//                }

                    int[] o = occurencesOfLetterAsBranching[w[i] - 'a'];
                    long add = (o[k] - (long) o[firstBranchingLevel - 1] * p2[k - firstBranchingLevel + 1]) % MOD;
                    if (add < 0) {
                        add += MOD;
                    }

                    ans += add;
                    if (ans >= MOD) {
                        ans -= MOD;
                    }
                }

                out.println(ans);
            }
        }

        class StringHasher {
            long[] h1;
            long[] h2;

            StringHasher(char[] s) {
                int n = s.length;
                h1 = new long[n + 1];
                h2 = new long[n + 1];
                for (int i = 0; i < n; i++) {
                    h1[i + 1] = (X1 * h1[i] + s[i]) % MOD1;
                    h2[i + 1] = (X2 * h2[i] + s[i]) % MOD2;
                }
            }

            long get1(int l, int r) {
                long res = (h1[r + 1] - pow1[r - l + 1] * h1[l]) % MOD1;
                if (res < 0) {
                    res += MOD1;
                }
                return res;
            }

            long get2(int l, int r) {
                long res = (h2[r + 1] - pow2[r - l + 1] * h2[l]) % MOD2;
                if (res < 0) {
                    res += MOD2;
                }
                return res;
            }

        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}