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;
#define P 1000000007
#define N 100005
#define M 2000005
char a[N],b[N],c[M],d[M];
int p[M],cf[N],qh[N][26],inv[N];
int pw(int x,int p){
	int ans=1;
	while(p){
		if(p&1)ans=1ll*ans*x%P;
		x=1ll*x*x%P;p>>=1;
	}return ans;
}
int main(){
	cf[0]=1;inv[0]=1;
	for(int i=1;i<N;++i)cf[i]=2*cf[i-1]%P,inv[i]=pw(cf[i],P-2);
	int n,q;
	scanf("%d%d",&n,&q);
	scanf("%s%s",b+1,a+1);
	for(int i=n;i>=1;--i){
		for(int j=0;j<26;++j)qh[i][j]=qh[i+1][j];
		qh[i][a[i]-'a']=(qh[i][a[i]-'a']+cf[n-i])%P;
	}
	int m1=strlen(b+1);
	for(int i=1;i<=q;++i){
		int k;scanf("%d",&k);
		scanf("%s",c+1);
		int m2=strlen(c+1);
		int t1=m1,t2=0;
		while(t1<m2)t1=t1*2+1,++t2;
		if(t2>k)puts("0");
		else{
			t1=m1;t2=0;
			for(int j=1;j<=m1;++j)d[j]=b[j];
			while(t1<m2){
				for(int j=1;j<=t1;++j)d[j+t1+1]=d[j];
				d[t1+1]=a[t2+1];
				++t2;t1=t1*2+1;	
			}
			for(int j=2;j<=m2;++j){
				int k=p[j-1];
				while(k&&c[k+1]!=c[j])k=p[k];
				if(c[k+1]==c[j])++k;
				p[j]=k;
			}int t=0,ans=0;
			for(int j=1;j<=t1;++j){
				while(t&&c[t+1]!=d[j])t=p[t];
				if(c[t+1]==d[j])++t;
				if(t==m2)ans++;
			}ans=1ll*ans*cf[k-t2]%P;
			for(int j=0;j<26;++j){
				int tp=t,sum=0;
				d[0]='a'+j;
				for(int k=0;k<m2;++k){
					while(tp&&c[tp+1]!=d[k])tp=p[tp];
					if(c[tp+1]==d[k])++tp;
					if(tp==m2)sum++;
				}
				ans=(ans+1ll*sum*(qh[t2+1][j]-qh[k+1][j])%P*inv[n-k])%P;
			}
			printf("%d\n",(ans+P)%P);
		}
	}
}