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>

using namespace std;
#define endl '\n'
#define maxn 4000100
#define maxm 100100

int n, q, k, len, s0len, p, inv2, qlen;
int sum[30][maxm], nxt[maxn];
char s0[maxn], t[maxn], qstr[maxn], s[maxn];
vector<pair<int, int> > v[30];
const int mod = 1e9 + 7;
int qpow(int a, int b) {
    int ret = 1;
    while (b) {
        if (b & 1) {
            ret = 1LL * ret * a % mod;
        }
        b >>= 1;
        a = 1LL * a * a % mod;
    }
    return ret;
}

void init() {
    len = s0len = strlen(s0);
    memcpy(s, s0, s0len);
    while (len <= 1e6 && p < n) {
        s[len] = t[++p];
        memcpy(s + len + 1, s, len);
        len = 2 * len + 1;
    }
    memcpy(s + len + 1, s, len);
    int b = 1, slen = 2 * s0len + 1;
    inv2 = qpow(2, mod - 2);
    int invn2 = qpow(inv2, n - 1);
    for (int i = n; i >= 1; i--, b = 2LL * b % mod) {
        for (int j = 0; j < 26; j++) {
            sum[j][i] = sum[j][i + 1];
        }
        sum[t[i] - 'a'][i] = (sum[t[i] - 'a'][i + 1] + b) % mod;
    }
//    for (int i = 1; i <= n; i++) {
//        for (int j = 0; j < 26; j++) {
//            cout << (char) ('a' + j) << ' ' << i << ' ' << sum[j][i] << endl;
//        }
//    }
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 26; j++) {
            sum[j][i] = 1LL * sum[j][i] * invn2 % mod;
        }
    }
    for (int i = 1; i <= n; i++, slen = min(slen * 2 + 1, (int) 2e6)) {
        v[t[i] - 'a'].push_back(make_pair(slen, i));
    }
    for (int i = 0; i < 26; i++) {
        v[i].push_back(make_pair((int) 8e6, n + 1));
    }
}

void getnext() {
    int kk = 0;
    for (int i = 2; i <= qlen; i++) {
        while (kk && qstr[i] != qstr[kk + 1]) {
            kk = nxt[kk];
        }
        if (qstr[kk + 1] == qstr[i]) {
            kk++;
        }
        nxt[i] = kk;
    }
}

int kmp(char *str, int l, int r) {
    int kk = 0, ret = 0;
    for (int i = l; i <= r; i++) {
        while (kk > 0 && qstr[kk + 1] != str[i]) {
            kk = nxt[kk];
        }
        if (qstr[kk + 1] == str[i]) {
            kk++;
        }
        if (kk == qlen) {
            ret++;
            kk = nxt[kk];
        }
    }
    return ret;
}

int solve() {
    qlen = strlen(qstr + 1);
    int ret = 0;
    getnext();
    int kk = kmp(s0, 0, s0len - 1);
    ret = 1LL * kk * qpow(2, k) % mod;
//    cout << ret << "***********" << (qstr + 1) << endl;
    int llen = s0len * 2 + 1, p = 1;
    while (llen < qlen && p <= k) {
        llen = llen * 2 + 1;
        p++;
    }
    s[len] = t[p];
    if (p <= k && qlen > s0len) {
        int kkkk = kmp(s, len - llen / 2, len + llen / 2);
        ret = (ret + 1LL * kkkk * qpow(2, k - p) % mod) % mod;
//        cout << len << ' ' << llen << ' ' << kkkk << ' ' << len - llen / 2 + 1 << ' ' << len + llen / 2 - 1 << ' ' << p
//             << ' ' << ret << endl;
    }
    int lllen = (qlen > s0len) ? llen + 2 : 2 * qlen - 1;
    for (int i = 0; i < 26; i++) {
        int pp = lower_bound(v[i].begin(), v[i].end(), make_pair(lllen, 0)) - v[i].begin();
        auto aa = v[i][pp];
//        cout << (char) ('a' + i) << ' ' << aa.second << endl;
        if (aa.second > k) {
            continue;
        }
        s[len] = 'a' + i;
        int k2 = qpow(2, k - 1);
        int kkk = kmp(s, len - qlen + 1, len + qlen - 1);
        ret = (ret + 1LL * kkk * ((sum[i][aa.second] - sum[i][k + 1]) % mod + mod) % mod * k2 % mod) % mod;
//        cout << (char) ('a' + i) << ' ' << kkk << ' ' << aa.second << ' ' << ret << ' '
//             << 1LL * ((sum[i][aa.second] - sum[i][k + 1]) % mod + mod) % mod * k2 % mod << ' ' << qlen << ' ' << aa
//                     .first << endl;
    }
    return ret;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n >> q;
    cin >> s0;
    cin >> (t + 1);
    init();
    while (q--) {
        cin >> k >> (qstr + 1);
        cout << solve() << endl;
    }
    return 0;
}