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 pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef __int128 lll;
typedef vector<int> vi;
typedef vector<ll> vl;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
const ll inf=0x3f3f3f3f3f3f3f3f;
const int mn=1e5+10;
const int ms=1e6+10;
const ll mod=1e9+7;

string s,t,rs,a,ra;
ll pf[mn][26],u[26];
int lcp[ms];
ll p2[mn];
ll comp(string&s,string&t){
    ll ans=0;
    int i,j;
    for(i=0,j=0;i<s.size();){
        if(j==t.size()) ans++,j=lcp[j-1];
        else if(s[i]==t[j])i++,j++;
        else if(j) j=lcp[j-1];
        else i++;
    }
    ans+=(j==t.size());
    return ans;
}

ll po(ll a,ll b){
    ll ans=1;
    for(;b;b>>=1,a*=a,a%=mod)if(b&1)ans*=a,ans%=mod;
    return ans;
}
int main(){
#ifdef LOCAL
    freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
freopen("error.txt","w",stderr);
#endif
    cin.tie(0);
    cin.sync_with_stdio(0);
    int n,q;
    cin>>n>>q;
    p2[0]=1;
    for(int i=1;i<=n;i++)p2[i]=p2[i-1]*2%mod;
    cin>>s>>t;
    rs=string(s.rbegin(),s.rend());
    stack<int>st;
    while(a.size()<ms){
        a+=s,ra+=rs;
        int nxt=0;
        while(st.size()&&st.top()==nxt)nxt++,st.pop();
        st.push(nxt);
        if(nxt>=n-1)break;
        a.push_back(t[nxt]);
        ra.push_back(t[nxt]);
    }
    cerr<<a.size()<<endl<<ra.size()<<endl;
    for(int i=1;i<=n;i++){
        memcpy(pf[i],pf[i-1],sizeof(pf[i]));
        pf[i][t[i-1]-'a']+=p2[n-i],pf[i][t[i-1]-'a']%=mod;
    }
    while(q--){
        string w;
        int k;
        cin>>k>>w;
        for(int i=1,j=0;i<w.size();){
            if(w[i]==w[j])lcp[i++]=++j;
            else if(j)j=lcp[j-1];
            else lcp[i++]=0;
        }
        ll ans=comp(s,w)*p2[n]%mod;
        memset(u,0,sizeof(u));
        for(int i=1,l=s.size();l<w.size()&&i<=k;l=l*2+1,i++){
            string tar;
            u[t[i-1]-'a']+=p2[n-i],u[t[i-1]-'a']%=mod;
            for(int j=min(l,int(w.size())-1)-1;j>=0;j--)tar+=ra[j];
            tar.push_back(t[i-1]);
            for(int j=0;j<min(l,int(w.size())-1);j++)tar+=a[j];
            ans+=comp(tar,w)*p2[n-i],ans%=mod;
        }
        for(int i=0;i<26;i++){
            string tar;
            for(int j=min(int(a.size()),int(w.size())-1)-1;j>=0;j--)tar+=ra[j];
            tar.push_back(i+'a');
            for(int j=0;j<min(int(a.size()),int(w.size())-1);j++)tar+=a[j];
            ans+=comp(tar,w)*(pf[k][i]-u[i]),ans%=mod;
        }
        ans*=po(2,mod-1-(n-k)),ans%=mod;
        if(ans<0)ans+=mod;
        printf("%lld\n",ans);
    }
}