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>
#define ls p<<1
#define rs p<<1|1 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define mm make_pair
#define pi 2*acos(0.0)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout.precision(i);cout<<fixed<<ans<<endl;
#define lowbit(x) (x)&(-x)
#define out(x) {cout<<x<<endl;return 0;} 
#define all(v) v.begin(),v.end() 
#define mem(x,i) memset(x,i,sizeof(x)) 
#define mec(x,y) memcpy(x,y,sizeof(y))
#define eps 1e-8 
#define ull unsigned long long
#define cps CLOCKS_PER_SEC
#define int long long
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
ll gcd(ll x,ll y){if(y==0) return x;else return gcd(y,x%y);} 
ll ksm(ll a,ll b){ll r=1;while(b){if(b&1) r=(r*a)%mod;a=a*a%mod;b>>=1;}return r;} 
void exgcd(ll a, ll b, ll &x, ll &y, ll &d){if(!b) d=a,x=1,y=0;else exgcd(b,a%b,y,x,d),y-=a/b*x;}
ll inv(ll a, ll p){ll x,y,d;exgcd(a,p,x,y,d);x=(x%p+p)%p;return x;}
inline int read()
{
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
const int maxn=1e6+100;
int n,m,k,q;
string s[205],t,w;
int p[maxn];
/*inline void pre_kmp(const string &b){
	nex[0]=0;
	int t=0,m=b.size();
	for(int i=1;i<m;i++){
		t=nex[i-1];
		if(b[t]!=b[i]&&t>0) t=nex[t];
		if(b[t]==b[i]) nex[i]=t+1;
		else nex[i]=0; 
	}
}
inline int kmp(const string &a,const string &b){
	int i=0,j=0;
	int n=a.size(),m=b.size(),cnt=0;
	while(i<n){
		if(a[i]==b[j]){
			i++;j++;
			if(j==m) j=nex[j-1],cnt++;
		}
		else{
			if(j==0) i++;
			else j=nex[j-1];
		}
	}
	return cnt;
}*/
void pre_kmp(const string& b)
{
    int lb=b.size();
    p[0]=0;
    for(int i=1,j=0;i<lb;i++)
    {
        while(j>0 && b[i]!=b[j]) j=p[j-1];
        if(b[i]==b[j]) j++;
        p[i]=j;
    }
    return ;
}
int kmp(const string &a,const string &b)
{
    //计算a中多少个b
    int sum=0,la=a.size(),lb=b.size();
    for(int i=0,j=0;i<la;i++)
    {
        while(j>0 && a[i]!=b[j]) 
            j=p[j-1];
        if(a[i]==b[j]) 
            j++;
        if(j==lb) 
        {
            sum++;
            j=p[j-1];
        }
    }
    return sum;
}
inline string work(const string &s,int m,char x){
	string w="";
	int n=s.size();
	for(int i=n-m+1;i<n;i++){
		w+=s[i];
	}
	w+=x;
	for(int i=0;i<m-1;i++){
		w+=s[i];
	}
	return w;
}
ll tw[maxn],f[27][maxn];
inline ll add(ll x,ll y){
	return (x+y)%mod;
}

signed main()
{
	fast;
	cin>>n>>q;
	cin>>s[0]>>t;
	int mx=0;
	
	//预处理 
	for(int i=0;i<t.size()&&s[i].size()<1000000+100;i++){
		s[i+1]=s[i]+t[i]+s[i];
	}
	tw[0]=1;
	for(int i=1;i<maxn;i++){
		tw[i]=tw[i-1]*2ll%mod;
	}
	for(int i=1;i<=t.size();i++){
		for(int j=0;j<26;j++){
			f[j][i]=f[j][i-1];
		}
		(f[t[i-1]-'a'][i]+=inv(tw[i],mod))%=mod;
	}//求出每一个t中的字符的贡献和 
	
	while(q--){
		ll ans=0;
		cin>>k>>w;
		pre_kmp(w); 
		for(int i=0;i<=k;i++){
			if(s[i].size()+1>=w.size()){
				for(int j=0;j<26;j++){
					string ss=work(s[i],w.size(),j+'a');
					ll cnt=kmp(ss,w);
					//cout<<ss<<endl; 
					(ans+=1ll*tw[k]*(f[j][k]-f[j][i]+mod)%mod *cnt%mod)%=mod;
				}
				if(s[i].size()>=w.size()){
					int cnt=kmp(s[i],w);
					(ans+=1ll* tw[k-i]* cnt%mod)%=mod;
				}
				break;
			}
		}
		cout<<(ans%mod+mod)%mod<<endl;
		
	}
	return 0;
}
/*
3 3
aa
bcd
3 ca
2 aba
3 aa

*/