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>
#define ll long long
#define pii pair<int,int>
#define vec vector
using namespace std;

const int MOD = 1e9 + 7;
int add(ll x, ll y) {return (x+y) % MOD;}
int mul(ll x, ll y) {return (x*y) % MOD;}
int bp(ll x, ll y) {
	int res = 1;
	while (y) {
		if (y&1) res = mul(res, x);
		x = mul(x, x);
		y>>=1;
	}
	return res;
}
int inv = bp(2, MOD-2);

int n, m, k, h, len, hlen;
string s, t, u, v;
vec<vec<int>> suff, cnt;
vec<int> lim;
vec<vec<bool>> valid;

int help(int pos, int stt, int covered) {
	assert(covered<len && stt<len);
	if (pos == h) return 0;
	if (covered+1 == len) {
		assert(stt<len);
		int tmp = add(suff[pos][v[stt]-'a'], MOD - suff[h][v[stt]-'a']);
		return mul(bp(inv, n-h), tmp);
	}
	
	assert(pos<hlen);
	int res = 0;
	for (int cur=0, bit=1<<pos; cur<=bit; cur+=bit) {
		if (stt+cur>=valid[pos].size() || !valid[pos][stt+cur] || cnt[pos][stt+cur]>lim[pos]) continue;
		assert(cnt[pos][stt+cur] > 0);
		res = add(res, help(pos+1, stt+bit-cur, covered+cnt[pos][stt+cur]));
	}
	return res;
}
int count() {
	if (v.empty()) return bp(2, h);
	len = v.size();
	hlen = min(h, (int)(sizeof(int)*8 - __builtin_clz(len)) + 2);
	lim = vec<int>(hlen);
	valid = vec<vec<bool>>(hlen);
	cnt = vec<vec<int>>(hlen);
	
	for (int p=0, pp=2; p<hlen; p++, pp<<=1) {
		lim[p] = (h-p-1<20 ? 1<<(h-p-1) : 1000*1000);
		valid[p] = vec<bool>(pp, 1);
		cnt[p] = vec<int>(pp);
		for (int i=0; i<pp; i++) {
			for (int j=i; j<len; j+=pp) {
				cnt[p][i]++;
				if (v[j] != t[p]) {
					valid[p][i] = 0;
					break;
				}
			}
		}
	}
	return help(0, 0, 0);
}
int solve() {
	cin >> h >> u;
	k = u.size();
	if (h<20 && (1ll<<h)*(m+1)-1 < k) return 0;
	
	int res = 0;
//	if (k <= m) {
//		for (int p=0; p<=m; p++) {
//			bool poss = 1;
//			for (int i=0, j=p; i<k && poss; i++) {
//				if (j == m) j = 0;
//				else poss = (u[i] == s[j++]);
//			}
//			if (!poss) continue;
//			if (m < p+k) v.push_back(u[k - (p+k-m)]);
//			cout << p << ' ' << v << ' ';
//			cout << count() << '\n';
//			res = add(res, count());
//			v.clear();
//		}
//	}
	for (int p=0; p<=m; p++) {
		bool poss = 1;
		for (int i=0, j=m-p; i<k && poss; i++) {
			if (j == m) j = 0;
			else poss = (u[i] == s[j++]);
		}
		if (!poss) continue;
		for (int i=p; i<k; i+=m+1) v.push_back(u[i]);
//		cout << p << ' ' << v << ' '; cout << count() << '\n';
		res = add(res, count());
		v.clear();
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifdef LOCAL
//		freopen("in1.txt", "r", stdin);
//		freopen("in1.txt", "w", stdout);
	#endif
	int tc;
	cin >> n >> tc;
	cin >> s >> t;
	m = s.size();
	suff = vec<vec<int>>(n+1, vec<int>(26));
	for (int i=n-1; i>=0; i--) {
		for (int j=0; j<26; j++) suff[i][j] = suff[i+1][j];
		suff[i][t[i]-'a'] = add(suff[i][t[i]-'a'], bp(2, n-i-1));
	}
	while (tc--) cout << solve() << '\n';
}