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;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define pii pair<int,int>

const int mod=1e9+7,p[2]={998244353,1000000007},N=2e6+5,M=1e5+5;
int n,q,len,pw[N][2],pre[M][26],pw2[N],ipw2[N],x,m,cnt[26],h[N][2],H[N][2];
char s[N],t[N],S[N],T[N];

void init(int n){
	pw[0][0]=pw[0][1]=1;
	for(int i=1;i<=n;i++) for(int j:{0,1}) pw[i][j]=233ll*pw[i-1][j]%p[j];
	pw2[0]=ipw2[0]=1;
	for(int i=1;i<=n;i++) pw2[i]=2ll*pw2[i-1]%mod;
	for(int i=1;i<=n;i++) ipw2[i]=1ll*(mod+1>>1)*ipw2[i-1]%mod;
	for(int i=1;i<=::n;i++){
		for(int j=0;j<26;j++) pre[i][j]=pre[i-1][j];
		pre[i][t[i]-'a']=(pre[i][t[i]-'a']+ipw2[i])%mod;
	}
}

void rehash(int n,char *s,int a[][2]){
	a[0][0]=a[0][1]=0;
	for(int i=1;i<=n;i++) for(int j:{0,1}) a[i][j]=(233ll*a[i-1][j]+s[i])%p[j];
}

pii que(int l,int r,int a[][2]){
	int x=(a[r][0]+1ll*(p[0]-a[l-1][0])*pw[r-l+1][0])%p[0];
	int y=(a[r][1]+1ll*(p[1]-a[l-1][1])*pw[r-l+1][1])%p[1];
	return pii(x,y);
}

void doit(){
	read(x);scanf("%s",T+1);m=strlen(T+1);
	int now=len,now2=0;
	for(int i=1;i<=len;i++) S[i]=s[i];
	while(now<m&&now2<x){
		now2++;
		S[now+1]=t[now2];
		for(int i=now+2;i<=now*2+1;i++) S[i]=S[i-now-1];
		now=now*2+1;
	}
	if(now<m) return puts("0"),void(0);
	rehash(now,S,h);
	rehash(m,T,H);
	for(int i=0;i<26;i++) cnt[i]=0;
	for(int i=1;i<=m;i++){
		int len=i-1;
		if(i==1||que(now-len+1,now,h)==que(1,i-1,H)){
			len=m-i;
			if(i==m||que(1,len,h)==que(i+1,m,H)) cnt[T[i]-'a']++;
		}
	}
	int ans=0;
	for(int i=1;i<=now-m+1;i++) if(que(i,i+m-1,h)==pii(H[m][0],H[m][1])) ans++;
	ans=1ll*ans*pw2[x-now2]%mod;
	for(int i=0;i<26;i++) ans=(ans+1ll*cnt[i]*(pre[x][i]+mod-pre[now2][i])%mod*pw2[x])%mod;
	write(ans);puts("");
}

signed main(){
	read(n,q);
	scanf("%s%s",s+1,t+1);
	len=strlen(s+1);
	init(2e6);
	while(q--) doit();
}