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;

const int N = 100000 + 9;
const int N2 = 2000000 + 9;
const long long P = 1000000007;
const long long inv2 = (P + 1) / 2;

char s[N2], t[N2], w[N2];
char a[N2], b[N2];
int Len[N], Id[N2];
long long Pow2[N], Pow2_inv[N];;
long long cnt[N][26];

struct Trie{
    int tot, ch[N][26], cnt[N];
    void insert(const char s[], int n){
        int o = 0;
        for (int i = 0; i < n; ++i){
            int c = s[i] - 'a';
            if (!ch[o][c]) ch[o][c] = ++tot;
            o = ch[o][c];
        }
        ++cnt[o];
    }
    int query(const char s[], int n){
        int o = 0;
        for (int i = 0; i < n; ++i){
            int c = s[i] - 'a';
            o = ch[o][c];
            if (!o) break;
        }
        return cnt[o];
    }
} trie;

struct KMP{
    int pi[N2], ans[N2];
    char *s;
    void get_pi(char _s[], int n){
        s = _s;
        for (int i = 1; i < n; ++i){
            for (int j = pi[i - 1]; ; j = pi[j - 1]){
                if (s[i] == s[j]){ pi[i] = j + 1; break; }
                else if (!j){ pi[i] = 0; break; }
            }
        }
    }
    int get_border(const char t[], int n){
        int cnt = 0, j = 0;
        for (int i = 0; i < n; ++i){
            for (; ; j = pi[j - 1]){
                if (t[i] == s[j]){ ++j; break; }
                else if (!j){ break; }
            }
        }
        while (j){ ans[++cnt] = j; j = pi[j - 1]; }
        ans[++cnt] = 0;
        return cnt;
    }
} kmp1, kmp2;

int main(){
    Pow2[0] = Pow2_inv[0] = 1;
    for (int i = 1; i < N; ++i){
        Pow2[i] = Pow2[i - 1] * 2 % P;
        Pow2_inv[i] = Pow2_inv[i - 1] * inv2 % P;
    }
    int n, q;
    scanf("%d %d", &n, &q);
    scanf("%s %s", s, t + 1);
    int sn = strlen(s);
    for (int i = 0; i < sn; ++i){
        for (int j = i; j < sn; ++j){
            trie.insert(s + i, j - i + 1);
        }
    }
    for (int i = n; i >= 1; --i){
        memcpy(cnt[i], cnt[i + 1], sizeof(cnt[0]));
        (cnt[i][t[i] - 'a'] += Pow2[n - i]) %= P;
    }
    int len = sn;
    Len[0] = sn;
    memcpy(a, s, len * sizeof(*s));
    for (int i = 1; i <= n; ++i){
        a[len] = t[i];
        memcpy(a + len + 1, a, len * sizeof(*a));
        len = len * 2 + 1;
        Len[i] = len;
        if (len >= N2 / 2) break;
    }
    Id[0] = 1;
    for (int i = 1; i <= N2 / 2; ++i){
        Id[i] = Id[i - 1];
        if (i > Len[Id[i] - 1]) ++Id[i];
    }
    memcpy(b, a, len * sizeof(*a));
    reverse(b, b + len);
    kmp1.get_pi(a, len);
    kmp2.get_pi(b, len);
    for (int i = 1; i <= q; ++i){
        int k;
        scanf("%d", &k);
        scanf("%s", w);
        int wn = strlen(w);
        long long ans = 0;
        int cnt0 = trie.query(w, wn);
        ans = (ans + cnt0 * Pow2[k]) % P;
        int cnt1 = kmp1.get_border(w, wn);
        reverse(w, w + wn);
        int cnt2 = kmp2.get_border(w, wn);
        for (int x = 1, y = cnt2; x <= cnt1 && y >= 1;){
            int tmp = kmp1.ans[x] + kmp2.ans[y];
            if (tmp < wn - 1) --y;
            else if (tmp == wn - 1){
                char ch = w[kmp1.ans[x]] - 'a';
                int id = min(Id[max(kmp1.ans[x], kmp2.ans[y])], k + 1);
                ans = (ans + (cnt[id][ch] - cnt[k + 1][ch]) * Pow2_inv[n - k]) % P;
                ++x; --y;
            }
            else ++x;
        }
        printf("%lld\n", (ans + P) % P);
    }
    return 0;
}