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

Solution:
#include <bits/stdc++.h>

const int mod = 1e9 + 7;

inline int add(int x, int y) {
    return x + y >= mod ? x + y - mod : x + y;
}
inline int sub(int x, int y) {
    return x - y >= 0 ? x - y : x - y + mod;
}
inline int power(int x, int y) {
    int res = 1;
    for (; y; y >>= 1, x = 1ll * x * x % mod) {
        if (y & 1) { res = 1ll * res * x % mod; }
    }
    return res;
}

const int N = 1e6 + 5;

int n, m, p, q, lens0, lent0, res, pwr[N], invpwr[N], f[N][27];
char s0[N], s[N], t0[N], t[N];

void dfs(int d, std::string t) {
    int m = t.size();
    if (m > 1) {
        char x = t[0], y = t[1];
        std::string gox, goy;
        for (int i = 0; i < m; i += 2) {
            if (t[i] != x) { x = '?'; }
            gox += t[i];
        }
        for (int i = 1; i < m; i += 2) {
            if (t[i] != y) { y = '?'; }
            goy += t[i];
        }
        if (x == s[d - 1]) {
            dfs(d + 1, goy);
        }
        if (y == s[d - 1]) {
            dfs(d + 1, gox);
        }
    } else {
        int x = t[0] - 'a';
        res = add(res, 1ll * sub(f[d - 1][x], f[p][x]) * pwr[p] % mod);
        return;
    }
}

int query() {
    if (m == 0) { return pwr[p]; }
    if (p <= 22 && m > pwr[p] - 1) { return 0; }
    std::string _t;
    for (int i = 0; i < m; i++) { _t += t[i]; }
    res = 0;
    dfs(1, _t);
    return res;
}

int main() {
    scanf("%d%d", &n, &q);
    scanf("%s%s", s0, s);
    lens0 = strlen(s0);
    pwr[0] = 1; invpwr[0] = 1;
    for (int i = 1; i <= n; i++) {
        pwr[i] = add(pwr[i - 1], pwr[i - 1]);
        invpwr[i] = power(pwr[i], mod - 2);
    }
    for (int i = n - 1; i >= 0; i--) {
        for (int x = 0; x < 26; x++) {
            f[i][x] = f[i + 1][x];
            if (s[i] - 'a' == x) {
                f[i][x] = add(f[i][x], invpwr[i + 1]);
            }
        }
    }
    for (; q; q--) {
        scanf("%d%s", &p, &t0);
        lent0 = strlen(t0);
        int ans = 0;
        for (int d = 0; d <= lens0; d++) {
            m = 0;
            bool ok = true;
            for (int i = 0, j = (lens0 - d) % lens0; i < lent0; i++) {
                if (i % (lens0 + 1) == d) {
                    t[m++] = t0[i];
                } else {
                    if (t0[i] != s0[j]) { ok = false; break; }
                    j = (j + 1) % lens0;
                }
            }
            if (!ok) { continue; }
            ans = add(ans, query());
        }
        printf("%d\n", ans);
    }
    return 0;
}