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 PI 3.14159265358979323846264338327950288419
#define mod 1000000007

using namespace std;

const int MAXLEN = 1000000;


int pow2[1000005];

int n, q;
int len[22], lim = 0;
string s[22], t;

int k;
string query;

int fail[2000005];
bool pref[2000005], suff[2000005];

int pre_joint[100005][26];
int joint[26];

void build_fail(string str) {
	fail[0] = -1;
	for (int i = 1; i < str.length(); i++) {
		fail[i] = fail[i - 1];
		while(fail[i] != -1 && str[i] != str[fail[i] + 1]) {
			fail[i] = fail[fail[i]];
		}
		if (str[i] == str[fail[i] + 1])
			fail[i]++;
	}
}

pair<int, int> find_match(string str, string tar) {
	int match = 0;
	int pos = -1;
	for (int i = 0; i < str.length(); i++) {
		while (pos != -1 && str[i] != tar[pos + 1]) {
			pos = fail[pos];
		}
		if (str[i] == tar[pos + 1]) {
			pos++;
			if (pos == tar.length() - 1) {
				match++;
				pos = fail[pos];
			}
		}
	}
	return {match, pos};
}


int main(){
	pow2[0] = 1;
	for (int i = 1; i <= 1000000; i++) {
		pow2[i] = pow2[i - 1] * 2 % mod;
	}
	
	ios::sync_with_stdio(false);
	
	cin >> n >> q;
	cin >> s[0] >> t;
	len[0] = s[0].length();
	for (int i = 0; len[i] <= MAXLEN; i++) {
		len[i + 1] = 2 * len[i] + 1;
		s[i + 1] = s[i] + t[i] + s[i];
		lim++;
	}
	
	// pre_joint[i][j] = number of occurrences of character j as "joint" in s[i]
	// with s[lim] as a block
	for (int i = lim + 1; i <= n; i++) {
		for (int j = 0; j < 26; j++) {
			pre_joint[i][j] = 2 * pre_joint[i - 1][j] % mod;
		}
		pre_joint[i][t[i - 1] - 'a']++;
	}
	
	while (q--) {
		cin >> k >> query;
		if (k <= lim && query.length() > len[k]) {
			printf("0\n");
			continue;
		}
		
		int tj = -1;
		for (int j = 0; j <= lim; j++) {
			if(len[j] >= query.length()){
				tj = j;
				break;
			}
		}
		
		assert(tj != -1 && tj <= k);
		
		// first count # occurrences in s[tj]
		// then count # occurrences in s[tj] + C + s[tj] for each character C
		// this can be done by matching prefix / suffix
		build_fail(query);
		pair<int, int> placeholder = find_match(s[tj], query);
		int occ_within = placeholder.first;
		int pos = placeholder.second;
		
		// within
		long long ans1 = 1LL * occ_within * pow2[k - tj] % mod;
		
		// across
		for (int i = 0; i < query.length(); i++) {
			pref[i] = false;
			suff[i] = false;
		}
		
		while (pos != -1) {
			pref[pos] = true;
			pos = fail[pos];
		}
		
		reverse(query.begin(), query.end());
		reverse(s[tj].begin(), s[tj].end());
		build_fail(query);
		pos = find_match(s[tj], query).second;
		reverse(query.begin(), query.end());
		reverse(s[tj].begin(), s[tj].end());
		
		while (pos != -1) {
			suff[query.length() - 1 - pos] = true;
			pos = fail[pos];
		}
/*
		cout << s[tj] << endl;
		for (int i = 0; i < query.length(); i++) {
			printf("%d", pref[i]);
		}
		puts("");
		for (int i = 0; i < query.length(); i++) {
			printf("%d", suff[i]);
		}
		puts("");
*/
		// calculate joint[]
		for (int i = 0; i < 26; i++) {
			joint[i] = pre_joint[k][i];
		}
		
		for (int i = tj + 1; i <= k && i <= lim; i++) {
			joint[t[i - 1] - 'a'] = (joint[t[i - 1] - 'a'] + pow2[k - i]) % mod;
		}
		
		long long ans2 = 0;
		for (int i = 0; i < query.length(); i++) {
			if (i > 0 && !pref[i - 1])
				continue;
			if (i + 1 < query.length() && !suff[i + 1])
				continue;
			ans2 = (ans2 + joint[query[i] - 'a']) % mod;
		}
		
		printf("%lld\n", (ans1 + ans2) % mod);
	}
	return 0;
}