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 fi first
#define se second
#define ULL unsigned long long
#define LL long long
#define PI std::pair<int,int>
#define MP std::make_pair
const int N=100005,M=1000005,MOD=1000000007;
int P;
struct hash{
	ULL a;
	int b;
	hash(){
		a=0,b=0;
	}
	hash(int x){
		a=x,b=x;
	}
	hash&operator+=(const hash&x){
		a+=x.a,b+=x.b;
		b>=P?b-=P:0;
		return*this;
	}
	hash&operator-=(const hash&x){
		a-=x.a,b-=x.b;
		b<0?b+=P:0;
		return*this;
	}
	hash&operator*=(const hash&x){
		a*=x.a,b=(LL)b*x.b%P;
		return*this;
	}
	hash operator+(const hash&x)const{
		hash t=*this;
		t+=x;
		return t;
	}
	hash operator-(const hash&x)const{
		hash t=*this;
		t-=x;
		return t;
	}
	hash operator*(const hash&x)const{
		hash t=*this;
		t*=x;
		return t;
	}
	bool operator==(const hash&x)const{
		return a==x.a&&b==x.b;
	}
	bool operator!=(const hash&x)const{
		return a!=x.a||b!=x.b;
	}
}
po[M*2],hs[M*2],sp[M*2],ss[M*2];
int n,m,tl,u,ql,po2[N],le[25],tcnt[26],cnt[N][26];
char a[N],s[25][M*2],qs[M];
bool match[M];
bool isprime(int x){
	for(int i=2;i*i<=x;i++) if(x%i==0)return 0;
	return 1;
}
int basic_qry(int x){
	if(le[x]<ql)return 0;
	int res=0;
	hash t(0);
	for(int i=1;i<=ql;i++)t=t*po[1]+(qs[i]-96);
	for(int i=ql;i<=le[x];i++){
		int p=i-ql;
		if(hs[i]-hs[p]*po[ql]==t)res++;
	}
	return res;
}
int main(){
	void*ttt=alloca(1);
	std::mt19937 ran(*(ULL*)&ttt^time(0));
	P=1000000000-ran()%100000000;
	while(!isprime(P))P++;
	po[1].a=ran()%10000000+27;
	while(!isprime(po[1].a))po[1].a++;
	po[1].b=ran()%10000000+27;
	while(!isprime(po[1].b))po[1].b++;
	po[0]=1;
	for(int i=2;i<=M*2-1;i++)po[i]=po[i-1]*po[1];
	po2[0]=1;
	for(int i=1;i<=N-1;i++)po2[i]=po2[i-1]*2%MOD;
	scanf("%d%d",&n,&m);
	memset(a,97,sizeof(a));
	scanf("%s%s",s[1]+1,a+1);
	tl=strlen(s[1]+1),u=1,le[1]=tl;
	while(tl<=1000000){
		for(int i=1;i<=tl;i++)s[u+1][i]=s[u][i];
		s[u+1][tl+1]=a[u];
		for(int i=1;i<=tl;i++)s[u+1][i+tl+1]=s[u][i];
		tl=tl*2+1;
		le[++u]=tl;
	}
	for(int i=u+1;i<=n+1;i++){
		for(int j=0;j<26;j++)cnt[i][j]=cnt[i-1][j]*2%MOD;
		cnt[i][a[i-1]-97]++;
	}
	for(int i=1;i<=tl;i++)hs[i]=hs[i-1]*po[1]+(s[u][i]-96);
	for(int i=1;i<=tl;i++)sp[i]=sp[i-1]+po[i-1]*(s[u][i]-96);
	for(int i=1;i<=tl;i++)ss[i]=ss[i-1]+po[i-1]*(s[u][tl+1-i]-96);
	while(m--){
		int x;
		scanf("%d%s",&x,qs+1);
		x++;
		ql=strlen(qs+1);
		int pos=1;
		while(le[pos]<ql)pos++;
		if(x<pos){
			puts("0");
			continue;
		}
		if(x==pos){
			printf("%d\n",basic_qry(x));
			continue;
		}
		for(int i=0;i<26;i++)tcnt[i]=cnt[x][i];
		for(int i=pos;i<=std::min(u,x)-1;i++)tcnt[a[i]-97]=(tcnt[a[i]-97]+po2[x-1-i])%MOD;
		int a1=basic_qry(pos),ans=(LL)a1*po2[x-pos]%MOD;
		hash t(0);
		for(int i=1;i<=ql;i++)match[i]=1;
		for(int i=1;i<=ql;i++){
			if(t!=ss[i-1])match[i]=0;
			t=t*po[1]+(qs[i]-96);
		}
		t=0;
		for(int i=ql;i;i--){
			if(t!=sp[ql-i])match[i]=0;
			t=t*po[1]+(qs[i]-96);
		}
		for(int i=1;i<=ql;i++) if(match[i])ans=(ans+tcnt[qs[i]-97])%MOD;
		printf("%d\n",ans);
	}
}