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 mp std::make_pair
#define pb push_back
#define fi first
#define se second
#define gc getchar
#define pc putchar
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef std::pair <int, int> pii;
const int mod = 1000000007;
const int max_N = 4117649;
const int mod1 = 998244353;
const int base1 = 666623333;
const int mod2 = 1004535809;
const int base2 = 19260817;
int n, q, s1_len, s3_len, T_len, cut, tax[100343][26];
char s1[max_N], s2[max_N], s3[max_N], T[max_N];
ll Hashl1[max_N / 3], Hashr1[max_N / 3], Hashl2[max_N / 3], Hashr2[max_N / 3];
ll power1[max_N / 3], power2[max_N / 3];
bool matchl[max_N], matchr[max_N];
int read() {
	char c = getchar(); int ans = 0; bool flag = true;
	while (!isdigit(c)) flag &= (c != '-'), c = gc();
	while (isdigit(c)) ans = ans * 10 + c - '0', c = gc();
	return flag ? ans : -ans;
}
void Write(int x) {
	static char _[16], top = 0; static div_t _div;
	while (!top || x) _div = div(x, 10), _[++top] = _div.rem + '0', x = _div.quot;
	while (top) pc(_[top--]);
}
int min(int x, int y) {return x < y ? x : y;}
int max(int x, int y) {return x > y ? x : y;}
void _min(int &x, int y) {if (x > y) x = y;}
void _max(int &x, int y) {if (x < y) x = y;}
ll power(ll x, int y, ll ans = 1) {
	for (; y; y >>= 1, x = x * x % mod)
		if (y & 1) ans = ans * x % mod;
	return ans;
}
int ctz(int x) {
	int ans = 0;
	if (!(x & 65535)) ans += 16, x >>= 16;
	if (!(x & 255)) ans += 8, x >>= 8;
	if (!(x & 15)) ans += 4, x >>= 4;
	if (!(x & 3)) ans += 2, x >>= 2;
	return ans + !(x & 1);
}
char test(int x) {
	if ((x - 1) % (s1_len + 1) < s1_len) return s1[(x - 1) % (s1_len + 1) + 1];
	return s2[ctz(x / (s1_len + 1)) + 1];
}
int get_match() {
	static int nxt[max_N]; int ans = 0;
	for (int i = 2; i <= s3_len; i++) {
		int j = nxt[i - 1];
		while (j && s3[j + 1] != s3[i]) j = nxt[j];
		nxt[i] = j + (s3[j + 1] == s3[i]);
	}
	for (int i = 1, j = 0; i <= T_len; i++)
		if (s3[j + 1] == T[i]) {
			j++;
			if (j == s3_len) ans++, j = nxt[j];
		}
		else {
			while (j && s3[j + 1] != T[i]) j = nxt[j];
			j += (s3[j + 1] == T[i]);
		}
	return ans;
}
int main() {
	n = read(), q = read(); scanf("%s%s", s1 + 1, s2 + 1); 
	s1_len = strlen(s1 + 1); int tmp = s1_len;
	for (int i = power1[0] = power2[0] = 1; i <= 1000000; i++)
		power1[i] = power1[i - 1] * base1 % mod1, power2[i] = power2[i - 1] * base2 % mod2;
	while (s1_len < 2050000)
		std::copy(s1 + 1, s1 + s1_len + 1, s1 + s1_len + 2),
		s1[s1_len + 1] = s2[++cut], s1_len = s1_len * 2 + 1;
	std::swap(s1_len, tmp);
	for (int i = 1; i <= 1000000; i++) {
		Hashl1[i] = (Hashl1[i - 1] * base1 + test(i)) % mod1,
		Hashl2[i] = (Hashl2[i - 1] * base2 + test(i)) % mod2,
		Hashr1[i] = (Hashr1[i - 1] * base1 + test(tmp + 1 - i)) % mod1,
		Hashr2[i] = (Hashr2[i - 1] * base2 + test(tmp + 1 - i)) % mod2;
	}
	for (int i = cut + 1; i <= n; i++) {
		std::copy(tax[i - 1], tax[i - 1] + 26, tax[i]);
		tax[i][s2[i] - 'a'] = (tax[i][s2[i] - 'a'] + power((mod + 1) / 2, i)) % mod;
	}
	for (int _ = 1, K; _ <= q; _++) {
		K = read(), scanf("%s", s3 + 1), s3_len = strlen(s3 + 1); int ans = 0;
		for (int i = 0, cur = s1_len; i <= min(cut, K); i++, cur = cur * 2 + 1) {
			if (cur < s3_len) continue;
			if (i == 0) std::copy(s1 + 1, s1 + 1 + s1_len, T + 1), T_len = s1_len;
			else {
				int low = max(1, (cur + 1) / 2 - s3_len + 1);
				int up = min(cur, (cur + 1) / 2 + s3_len - 1);
				T_len = up - low + 1, std::copy(s1 + low, s1 + up + 1, T + 1);
			}
			ans = (ans + power(2, K - i, get_match())) % mod;
		}
		if (K > cut) {
			for (int i = 0; i <= s3_len + 1; i++) matchl[i] = matchr[i] = true;
			for (int i = s3_len, prod = 0; i; i--)
				prod = (prod + s3[i] * power1[s3_len - i]) % mod1,
				matchl[s3_len - i + 1] &= (prod == Hashl1[s3_len - i + 1]);
			for (int i = s3_len, prod = 0; i; i--)
				prod = (prod + s3[i] * power2[s3_len - i]) % mod2,
				matchl[s3_len - i + 1] &= (prod == Hashl2[s3_len - i + 1]);
			for (int i = 1, prod = 0; i <= s3_len; i++)
				prod = (prod + s3[i] * power1[i - 1]) % mod1,
				matchr[i] &= (prod == Hashr1[i]);
			for (int i = 1, prod = 0; i <= s3_len; i++)
				prod = (prod + s3[i] * power2[i - 1]) % mod2,
				matchr[i] &= (prod == Hashr2[i]);
			for (int i = 1; i <= s3_len; i++) if (matchl[s3_len - i] && matchr[i - 1])
				ans = (ans + tax[K][s3[i] - 'a'] * power(2, K)) % mod;
		}
		Write(ans), pc('\n');
	}
	return 0;
}