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;
using ll = long long;
const int mod = 1e9+7;
int add(int a, int b) {
	return a + b < mod ? a + b : a + b - mod;
}
int mul(int a, int b) {
	return int(1LL * a * b % mod);
}

const int N = 1000006;
int b[N];

void rprefix_function(const string &s, int n){
	b[0] = -1; int i = 0, j = -1;
	while(i < n){
		while(j >= 0 && s[n - 1 - i] != s[n - 1 - j]) j = b[j];
		b[++i] = ++j;
	}
}
void prefix_function(const string &s, int n){
	b[0] = -1; int i = 0, j = -1;
	while(i < n){
		while(j >= 0 && s[i] != s[j]) j = b[j];
		b[++i] = ++j;
	}
}
int last_pos;
int rkmp(const string &t, int n, const string &p, int m){
	rprefix_function(p, m);
	int cnt = 0;
	int j = 0;
	for(int i = 0; i < n; i++){
		while(j >= 0 && t[n - 1 - i] != p[m - 1 - j]) j = b[j];
		j++;
		if(j == m) {
			//patern of p found on t
			cnt++;
			j = b[j];
		}
	}
	last_pos = j;
	return cnt;
}
int kmp(const string &t, int n, const string &p, int m){
	prefix_function(p, m);
	int cnt = 0;
	int j = 0;
	for(int i = 0; i < n; i++){
		while(j >= 0 && t[i] != p[j]) j = b[j];
		j++;
		if(j == m) {
			//patern of p found on t
			cnt++;
			j = b[j];
		}
	}
	last_pos = j;
	return cnt;
}

int n, q;
string s0, s;
string t;
int pw[N], ipw[N];
int pref[N], suf[N];
int ps[N][26];

void solve() {
	int k;
	string p;
	cin >> k >> p;

	int me = 0;
	int len = (int)s0.size();
	for(int i = 0; i < (int)t.size() and len < (int)p.size(); i++) {
		len = len + 1 + len;
		me++;
	}
	if(me > k or len < (int)p.size()) {
		printf("0\n");
		return;
	}
	// printf("%d %d\n", me, len);
	// printf("TODO\n");
	int ans = kmp(s, len, p, (int)p.size());
	ans = mul(ans, pw[k - me]);

	for(int i = 0; i <= len; i++) {
		pref[i] = suf[i] = 0;
	}

	for(int j = last_pos; j != -1; j = b[j]) {
		suf[len - j] = 1;
	}
	rkmp(s, len, p, (int)p.size());
	for(int j = last_pos; j != -1; j = b[j]) {
		pref[j] = 1;
	}
	// cout << last_pos << endl;

	/*for(int i = 0; i <= len; i++) {
		printf("%d pref %d suf %d\n", i, pref[i], suf[i]);
	}*/

	pref[0] = suf[len] = 1;

	int m = (int)p.size();

	for(int i = len - m + 1; i <= len; i++) if(suf[i] and pref[m - (len - i) - 1]) {
		int pos = int(p[len - i] - 'a');
		int toadd = add(ps[k][pos], mod - mul(ps[me][pos], pw[k - me]));
		ans = add(ans, toadd);
		//printf("toADD %d char %c from %d to %d\n", toadd, p[len - i], me + 1, k);	
	}

	printf("%d\n", ans);
}

int main() {
	// ios::sync_with_stdio(false); cin.tie(nullptr);

	pw[0] = 1;
	for(int i = 1; i < N; i++) {
		pw[i] = add(pw[i - 1], pw[i - 1]);
	}
	ipw[0] = 1, ipw[1] = (mod + 1) / 2;
	for(int i = 2; i < N; i++) {
		ipw[i] = mul(pw[i - 1], ipw[1]);
	}

	cin >> n >> q;
	cin >> s0 >> t;
	s = s0;

	// cout << t << endl;

	for(int i = 1; i <= n; i++) {
		for(int j = 0; j < 26; j++) {
			ps[i][j] = add(ps[i - 1][j], ps[i - 1][j]);
		}
		ps[i][int(t[i - 1] - 'a')]++;
	}
	for(char c : t) {
		if((int)s.size() >= 1000000) break;
		s = s + c + s;
	}

	while(q--) {
		solve();
	}
}