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;

const int maxn=2000010;
struct node {
	int a,b; node(){}
	node(int a,int b):a(a),b(b){}
	friend ostream& operator <<(ostream& out,node x){ return out<<"("<<x.a<<","<<x.b<<")"; }  
} base(131,137),Hmod(1e9+7,1e9+9);
bool operator==(node x, node y) { return x.a==y.a&&x.b==y.b; }
node operator*(node x, node y) { return node(1ll*x.a*y.a%Hmod.a,1ll*x.b*y.b%Hmod.b); }
node operator+(node x, char c) { return node((x.a+c)%Hmod.a,(x.b+c)%Hmod.b); }
node operator+(node x, node y) { return node((x.a+y.a)%Hmod.a,(x.b+y.b)%Hmod.b); }
node operator-(node x, node y) { return node((x.a+Hmod.a-y.a)%Hmod.a,(x.b+Hmod.b-y.b)%Hmod.b); }
struct mybase{
	node bas[maxn];
	mybase(){ 
		bas[0]={1,1};
		for(int i=1;i<maxn;i++) bas[i]=bas[i-1]*base;
	}
} B;
struct myhash{
	vector<node> has;
    // 注意哈希数组从1开始存，高位在左
    myhash(string &s){
		has.reserve(s.size()+1);
		has.push_back({0,0});
        for(int i=0;i<int(s.size());i++) has.push_back(has[i]*base+s[i]);
    }
	node str(int l,int r){
		return has[r]-has[l-1]*B.bas[r-l+1];
	}
};

#define ll long long
const ll mod=1e9+7;
ll mypow(ll a,ll b){
    ll ret=1;
    while(b){
        if(b&1)ret=ret*a%mod;
        a=a*a%mod;b>>=1;
    }
    return ret;
}
ll dp[26][100010];
ll p2[100010];
int main(){
	ios::sync_with_stdio(0);cin.tie(0);
    int N,q;cin>>N>>q;
	string s,t;cin>>s>>t;
	// 260W
	p2[0]=1;
	for(int i=1;i<=N;i++){
		p2[i]=p2[i-1]*500000004%mod;
		for(int j=0;j<26;j++){
			dp[j][i]=dp[j][i-1];
			if(j+'a'==t[i-1]) dp[j][i]=(dp[j][i]+mypow(2,N-i))%mod;
		}
	}
	while(q--){
		int k;cin>>k;string p;cin>>p;
		string now=s;int ind=0;
		// 200W
		while(ind<k&&p.size()>now.size()) now=now+t[ind++]+now;

		int n=now.size(),m=p.size(),ret=0;
		myhash h1(now),h2(p);
		for(int i=1;i<=n-m+1;i++){
			ret+=h2.str(1,m)==h1.str(i,m+i-1);
		}
		ll ans=ret*mypow(2,k-ind)%mod;

		// 260W*lg
		ll cnt[26]={};
		for(int i=0;i<26;i++) cnt[i]=(dp[i][k]+mod-dp[i][ind])*p2[N-k]%mod;
		
		for(int i=0;i<m;i++){
			if(i<=n&&m-i-1<=n&&h1.str(n-i+1,n)==h2.str(1,i)&&h1.str(1,m-i-1)==h2.str(i+2,m))
				ans=(ans+cnt[p[i]-'a'])%mod;
		}
		cout<<ans<<"\n";
	}
}