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:
/**
 *  created: 30/12/2020, 18:01:30
**/

#include <bits/stdc++.h>

using namespace std;

const int max_n = 100111, mod = 1000000007;
const int max_len = 1000111;

char buf[max_len];

string read() {
    scanf("%s", buf);
    return buf;
}

inline void inc(int &x, int y) {
    x += y;
    if (x >= mod) {
        x -= mod;
    }
}

int mul(int x, int y) {
    return 1LL * x * y % mod;
}

const int max_c = 26;

int n, q, len, pw[max_n], rpw[max_n], sum[max_c][max_n];
string s0, t;

int get_sum(int c, int l, int r) {
    if (!l) {
        return sum[c][r];
    }
    return (sum[c][r] + mod - sum[c][l - 1]) % mod;
}

int rec(int pos, const string &s) {
    //cout << pos << " " << len << " " << s << endl;
    if (pos > len) {
        return 0;
    }
    if (s.empty()) {
        return pw[len - pos];
    }
    if (pos >= len) {
        return 0;
    }
    if (s.size() == 1) {
        return mul(pw[len - 1], get_sum(s[0] - 'a', pos, len - 1));
    }
    string a[2];
    for (int i = 0; i < s.length(); ++i) {
        a[i % 2] += s[i];
    }
    int res = 0;
    for (int to = 0; to < 2; ++to) {
        if (a[to ^ 1] == string(a[to ^ 1].length(), t[pos])) {
            inc(res, rec(pos + 1, a[to]));
        }
    }
    return res;
}

int solve(const string &s) {
    int res = rec(0, s);
    //cout << s << ": " << res << endl;
    return res;
}

void init() {
    const int r2 = (mod + 1) / 2;
    pw[0] = 1;
    rpw[0] = 1;
    for (int i = 1; i < max_n; ++i) {
        pw[i] = mul(pw[i - 1], 2);
        rpw[i] = mul(rpw[i - 1], r2);
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    init();
    scanf("%d%d", &n, &q);
    s0 = read();
    t = read();
    for (int i = 0; i < t.length(); ++i) {
        if (i) {
            for (int c = 0; c < max_c; ++c) {
                sum[c][i] = sum[c][i - 1];
            }
        }
        inc(sum[t[i] - 'a'][i], rpw[i]);
    }
    s0 += '?';
    while (q--) {
        scanf("%d", &len);
        string s = read();
        int ans = 0;
        for (int i = 0; i < s0.length(); ++i) {
            string need;
            bool ok = 1;
            for (int j = 0; j < s.length() && ok; ++j) {
                if (s0[j % s0.length()] == '?') {
                    need += s[j];
                } else {
                    ok &= s[j] == s0[j % s0.length()];
                }
            }
            if (ok) {
                //cout << s0 << "   ";
                inc(ans, solve(need));
            }
            rotate(s0.begin(), s0.begin() + 1, s0.end());
        }
        printf("%d\n", ans);
    }
    return 0;
}