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<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
#define N 1000012
typedef long long ll;
const int p=1e9+7,bas=233,bas2=2333,p2=998244853,iv=5e8+4;
int n,Q,xs[N][26],bin[N],bsn[N<<2],bsn2[N<<2],sl,tot,ib[N];
int ha[N<<2],ha2[N<<2];
char s[N],t[N],ch[N],tc[N<<2],nc[N<<2];
inline int geh(int l,int r)
{
	return (ha[r]-1ll*ha[l-1]*bsn[r-l+1]%p+p)%p;
}
inline int geh2(int l,int r)
{
	return (ha2[r]-1ll*ha2[l-1]*bsn2[r-l+1]%p2+p2)%p2;
}
int main()
{
	ib[0]=1;for(int i=1;i<=1000000;i++)ib[i]=1ll*ib[i-1]*iv%p;
	bin[0]=1;for(int i=1;i<=1000000;i++)bin[i]=2ll*bin[i-1]%p;
	bsn[0]=bsn2[0]=1;
	for(int i=1;i<=4000000;i++)bsn[i]=1ll*bsn[i-1]*bas%p,bsn2[i]=1ll*bsn2[i-1]*bas2%p2;
	scanf("%d%d",&n,&Q);
	scanf("%s%s",s+1,t+1);sl=strlen(s+1);
	for(int i=n;i;i--)
	{
		for(int j=0;j<26;j++)xs[i][j]=xs[i+1][j];
		(xs[i][t[i]-'a']+=bin[n-i])%=p;
	}
	while(Q--)
	{
		int tk=0,k;scanf("%d",&k);tot=0;
		scanf("%s",ch+1);int len=strlen(ch+1);
		if(sl<len)
		{
			for(int i=1;i<=sl;i++)tc[++tot]=s[i];
			for(int i=1;i<=k;i++)
			{
				tc[++tot]=t[i];int lt=tot;
				for(int j=1;j<lt;j++)tc[++tot]=tc[j];
				if(tot>=len){tk=i;break;}
			}
			if(tot<len)tk=-1;
		}
		if(tk==-1){puts("0");continue;}
		int mh=0,mh2=0,fk=0,nt=0;
		if(sl<len)
		{
			for(int i=1;i<=tot;i++)ha[i]=(1ll*ha[i-1]*bas%p+tc[i]-'a'+1)%p,
			ha2[i]=(1ll*ha2[i-1]*bas2%p2+tc[i]-'a'+1)%p2;
			for(int i=1;i<=len;i++)mh=(1ll*mh*bas%p+ch[i]-'a'+1)%p,mh2=(1ll*mh2*bas2%p2+ch[i]-'a'+1)%p2;
			for(int i=1;i+len-1<=tot;i++)if(geh(i,i+len-1)==mh&&geh2(i,i+len-1)==mh2)fk++;
		}
		else
		{
			for(int i=1;i<=sl;i++)ha[i]=(1ll*ha[i-1]*bas%p+s[i]-'a'+1)%p,
			ha2[i]=(1ll*ha2[i-1]*bas2%p2+s[i]-'a'+1)%p2;
			for(int i=1;i<=len;i++)mh=(1ll*mh*bas%p+ch[i]-'a'+1)%p,mh2=(1ll*mh2*bas2%p2+ch[i]-'a'+1)%p2;
			for(int i=1;i+len-1<=sl;i++)if(geh(i,i+len-1)==mh&&geh2(i,i+len-1)==mh2)fk++;
		}
		if(sl<len)
		{
			for(int i=tot+1-len+1;i<=tot;i++)nc[++nt]=tc[i];
			for(int i=nt+2;i<=nt+len;i++)nc[i]=tc[i-nt-1];
		}
		else
		{
			for(int i=sl-len+2;i<=sl;i++)nc[++nt]=s[i];
			for(int i=nt+2;i<=nt+len;i++)nc[i]=s[i-nt-1];
		}
		fk=1ll*fk*bin[k-tk]%p;
		for(int i=0;i<26;i++)
		{nc[nt+1]='a'+i;
			for(int j=1;j<=2*nt+1;j++)ha[j]=(1ll*ha[j-1]*bas%p+nc[j]-'a'+1)%p,
			ha2[j]=(1ll*ha2[j-1]*bas2%p2+nc[j]-'a'+1)%p2;
			int ct=0;
			for(int j=1;j+len-1<=2*nt+1;j++)if(geh(j,j+len-1)==mh&&geh2(j,j+len-1)==mh2)ct++;
			fk=(fk+1ll*ct*(xs[tk+1][i]-1ll*xs[k+1][i]+p)%p*ib[n-k]%p)%p;
		}
		printf("%d\n",fk);
	}
}
/*
3 1
aa
bcd
2 aba
*/