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:
/*
    Coded with Leachim's ACM Template.
    No errors. No warnings. ~~
*/
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-const-variable"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wsign-compare"
#define LL long long
using namespace std;
const int inf=0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-7;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};
const int RT=3;
const int MOD=1e9+7;
const int MAXN=2000005;

int nxt[MAXN];
char s[MAXN],t[MAXN],ss[MAXN],st[MAXN];

int kmp(char *s1, char *s2, int *nxt){
    int n=strlen(s1),m=strlen(s2);

    nxt[0]=-1;
    for(int i=1,k=-1;i<=m;i++){
        //k初始值为-1. nxt数组可以查询boarder的boarder.
        while(~k && s2[k]!=s2[i-1])
            k=nxt[k];
        nxt[i]=++k;
    }

    int cnt=0;
    for(int i=1,k=0;i<=n;i++){
        //匹配串前缀与模式串后缀比，上一位前缀的boarder的boarder也能匹配。
        while(~k && s2[k]!=s1[i-1])
            k=nxt[k];
        if(m==++k) cnt++;
    }
    return cnt;
}

int binpow(int x,int y,int m) {
    int r=1%m;
    while(y) {
        if(y&1) r=1LL*r*x%m;
        x=1LL*x*x%m;
        y>>=1;
    }
    return r;
}

int cnt[26],sum[26][MAXN];

void solve() {
    int n,q;
    scanf("%d %d", &n, &q);
    scanf("%s %s", s, t+1);
    int ls=strlen(s);
    for(int i=1;i<=n;i++) {
        for(int k=0;k<26;k++)
            sum[k][i]=sum[k][i-1];
        sum[t[i]-'a'][i]=(sum[t[i]-'a'][i]+binpow(2,n-i,MOD))%MOD;
    }
    // for(int k=0;k<26;k++) {
    //     for(int i=1;i<=n;i++)
    //         printf("%d%c", sum[k][i], " \n"[i==n]);
    // }
    for(int i=1;i<=q;i++) {
        int k;
        scanf("%d", &k);
        scanf("%s", ss);
        int lss=strlen(ss);
        int len=ls;
        int kk=0;
        s[len]=0;
        while(len<lss && ++kk<=k) {
            s[len]=t[kk];
            for(int i=0;i<len;i++)
                s[len+i+1]=s[i];
            len=len<<1|1;
            s[len]=0;
        }

        // printf("\n%s\n", s);
        // printf("%d %d\n", k,kk);

        if(len<lss) {
            printf("0\n");
        } else {
            for(int i=0;i<lss-1;i++)
                st[i]=s[len-lss+1+i];
            for(int i=0;i<lss-1;i++)
                st[lss+i]=s[i];
            st[lss*2-1]=0;

            for(int i=0;i<26;i++) {
                st[lss-1]=i+'a';
                cnt[i]=kmp(st,ss,nxt);
            }
            int ans=1LL*kmp(s,ss,nxt)*binpow(2,k-kk,MOD)%MOD;
            for(int j=0;j<26;j++) {
                ans=(ans+1LL*cnt[j]*(sum[j][k]-sum[j][kk]+MOD)%MOD*binpow(binpow(2,n-k,MOD),MOD-2,MOD)%MOD)%MOD;
            }
            printf("%d\n", ans);
        }
    }
}

int main() {
    int T=1,cas=1;(void)(cas);
    // scanf("%d", &T);
    while(T--) {
        // printf("Case #%d: ", cas++);
        solve();
    }
    return 0;
}