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;
typedef long long ll;typedef double db;
typedef pair<int, int> pii;typedef pair<ll, ll> pll;
typedef pair<int,ll> pil;typedef pair<ll,int> pli;
#define Fi first
#define Se second
#define _Out(a)	cerr<<#a<<" = "<<(a)<<endl
const int INF = 0x3f3f3f3f, MAXN = 2e5 + 5;
const ll LINF = 0x3f3f3f3f3f3f3f3f, MOD = 1e9+7;
const db Pi = acos(-1), EPS = 1e-6;
void test(){cerr << "\n";}template<typename T,typename...Args>void test(T x,Args...args){cerr<<x<<" ";test(args...);}
inline ll qpow(ll a, ll b){return b?((b&1)?a*qpow(a*a%MOD,b>>1)%MOD:qpow(a*a%MOD,b>>1))%MOD:1;}
inline ll qpow(ll a, ll b,ll c){return b?((b&1)?a*qpow(a*a%c,b>>1,c)%c:qpow(a*a%c,b>>1,c)) %c:1;}
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll cede(ll a,ll b){if(b<0)return cede(-a,-b);if(a<0)return a/b;return (a+b-1)/b;}
inline ll flde(ll a,ll b){if(b<0)return flde(-a,-b);if(a<0)return (a-b+1)/b;return a/b;}
inline int sign(db x){return x<-EPS ? -1:x>EPS;}
inline int dbcmp(db l,db r){return sign(l - r);}


char s0[MAXN];
char t[MAXN*10];
char tmp[MAXN*10];
char zzz[MAXN*10];
int cntS;
ll cnttree[MAXN][27];
int xz;
string ssss[MAXN*10];
int used=0;
ll getans(string &s,int pos)
{
    if(s.length()==0)
    {
        return 1ll;
    }
    if(s.length()==1)
    {
        if(pos>xz)return 0;
        return (cnttree[xz][s[0]-'a']-cnttree[pos-1][s[0]-'a']+MOD)%MOD;
    }
    string &l=ssss[++used],&r=ssss[++used];
    l.clear();r.clear();
    for(int i=0;i<s.length();i+=2)l+=s[i];
    for(int i=1;i<s.length();i+=2)r+=s[i];
    bool okl=1,okr=1;
    for(int i=0;i<l.length();i++)okl&=(l[i]==t[pos]);
    for(int i=0;i<r.length();i++)okr&=(r[i]==t[pos]);
    ll ans=0;
    if(okl)ans=(ans+getans(r,pos+1))%MOD;
    if(okr)ans=(ans+getans(l,pos+1))%MOD;
    return ans%MOD;
}
void work()
{
    int n,q;
    scanf("%d%d",&n,&q);
    int lena,lenb;scanf("%s%s",s0+1,t+1);
    lena=strlen(s0+1);
    lenb=strlen(t+1);
    /*Getstr(s0+1,lena);
    Getstr(t+1,lenb);*/
    for(int i=1;i<=lenb;i++)
    {
        ll gx=qpow(2,i);
        gx=qpow(gx,MOD-2)%MOD;
        for(int j=0;j<26;j++)cnttree[i][j]=(cnttree[i-1][j]+(t[i]==j+'a')*gx)%MOD;
    }
    for(int i=1;i<=q;i++)
    {
        int m;
        scanf("%d",&xz);
        //Getstr(tmp+1,m);
        scanf("%s",tmp+1);
        m=strlen(tmp+1);
        ll ans=0;
        for(int j=0;j<=lena;j++)
        {
            int now=j;
            cntS=0;bool ok=1;
            
            for(int k=1;k<=m;k++)
            {
                if(now==0)zzz[++cntS]=tmp[k];
                else
                {
                    if(tmp[k]!=s0[now])ok=0;
                }
                now++;
                now%=(lena+1);
            }
            zzz[++cntS]=0;
            ssss[0].clear();
            ssss[0]=zzz+1;
            used=1;

            if(ok)ans=(ans+getans(ssss[0],1))%MOD;
        }
        printf("%lld\n",ans*qpow(2,xz)%MOD);
    }
}
int main()
{
    work();
}