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 rep(i,a,b) for(int i = (a); i < b; ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define trav(x, v) for(auto &x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) (int)(v).size()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll md = 1e9+7;
const ll prime = 826301243804089, base = 5131; 

int occs(string &t, string &s){
	// how many times is t in s
	if(sz(t) > sz(s)) return 0;
	ll tval = 0, sval = 0;
	trav(c, t) tval = (tval * base + c-'a') % prime;
	rep(i,0,sz(t)) sval = (sval * base + s[i]-'a') % prime;
	int ans = tval == sval;
	ll bp = 1;
	rep(_,0,sz(t)) bp = bp * base % prime;
	rep(i,sz(t),sz(s)){
		sval = (sval * base + s[i]-'a' - (s[i-sz(t)]-'a') * bp) % prime;
		if((sval - tval) % prime == 0) ++ans;
	}
	return ans;
}

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);
	cin.exceptions(cin.failbit);

	int n, q;
	cin >> n >> q;

	string s0, t;
	cin >> s0 >> t;
	string sb = s0;
	vi lob(1e6, n);
	rep(i,0,sz(s0)+1) lob[i] = 0;
	rep(i,0,sz(t)) if(sz(sb) < 1e6){
		int pr = sz(sb);
		sb = sb + t[i] + sb;
		rep(j,pr+1,min(sz(sb)+1, int(1e6))) lob[j] = i+1;
	}

	vector<vl> pret(n+1, vl(27, 0));
	pret[0][26] = 1;
	rep(i,0,n){
		rep(tt,0,27)
			pret[i+1][tt] = pret[i][tt] * 2 % md;
		++pret[i+1][t[i]-'a'];
	}

	rep(_,0,q){
		int k;
		cin >> k;
		string w;
		cin >> w;

		ll ans = occs(w, s0) * pret[k][26] % md;

		vector<bool> good(sz(w), true);
		ll sval = 0, tval = 0, bp = 1;
		rep(i,0,sz(w)-1){
			tval = (tval * base + w[i] - 'a') % prime;
			sval = (sval + bp * (sb[sz(sb)-1-i]-'a')) % prime;
			bp = bp * base % prime;
			good[i+1] = (good[i+1] && (sval - tval) % prime == 0);
		}
		bp = 1, sval = tval = 0;
		rrep(i,0,sz(w)-1){
			tval = (tval + bp * (w[i+1]-'a')) % prime;
			sval = (sval * base + sb[sz(w)-2-i] - 'a') % prime;
			bp = bp * base % prime;
			good[i] = (good[i] && (sval - tval) % prime == 0);
		}

		rep(i,0,sz(w)) if(good[i]){
			int fr = lob[max(i, sz(w)-i-1)];
			if(fr >= k) continue;
			ans = (ans + pret[k][w[i]-'a'] - pret[k-fr][26] * pret[fr][w[i]-'a']) % md;
		}

		if(ans < 0) ans += md;
		cout << ans << endl;
	}
}