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 <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 2000005
#define ll long long
#define mod 1000000007
int n, m, q, t, F[27][N], nex[N];
int mul[N], inv[N];
char S[N << 2], T[N], G[N];
int Pow(int a, int k)
{
	int ret = 1;
	while (k)
	{
		if (k & 1)
			ret = (ll)ret * a % mod;
		a = (ll)a * a % mod;
		k >>= 1;
	}
	return ret;
}
void Getnex(char *A, int n)
{
	nex[1] = 0;
	for (int i = 2; i <= n; i++)
	{
		nex[i] = nex[i - 1];
		while (nex[i] && A[nex[i] + 1] != A[i])
			nex[i] = nex[nex[i]];
		if (A[nex[i] + 1] == A[i])
			nex[i]++;
	}
}
int Getkmp(char *A, int n, char *B, int m)
{
	int x = 0, ans = 0;
	for (int i = 1; i <= n; i++)
	{
		while (x && B[x + 1] != A[i])
			x = nex[x];
		if (B[x + 1] == A[i])
			x++;
		ans += (x == m);
	}
	return ans;
}
int main()
{
	scanf("%d%d", &n, &q);
	mul[0] = 1;
	for (int i = 1; i <= n; i++)
		mul[i] = 2ll * mul[i - 1] % mod;
	inv[0] = 1;
	for (int i = 1; i <= n; i++)
		inv[i] = 500000004ll * inv[i - 1] % mod;

	scanf("%s%s", S + 1, T + 1);
	for (int i = n; i >= 1; i--)
	{
		for (int j = 1; j <= 26; j++)
			F[j][i] = F[j][i + 1];
		F[T[i] - 'a' + 1][i] = (F[T[i] - 'a' + 1][i] + mul[n - i]) % mod;
	}

	m = strlen(S + 1);
	while (q--)
	{
		scanf("%d%s", &t, G + 1);
		int p = strlen(G + 1);
		Getnex(G, p);

		int k = 0, l = m;
		while (k < t && l < p)
		{
			k++;
			S[l + 1] = T[k];
			for (int j = 1; j <= l; j++)
				S[l + j + 1] = S[j];
			l = l * 2 + 1;
		}
		if (l < p)
		{
			puts("0");
			continue;
		}
		int s = Getkmp(S, l, G, p);
		int sum = (ll)mul[t - k] * s % mod;
		for (int i = 1; i <= l; i++)
			S[l + i + 1] = S[i];
		for (int i = 1; i <= 26; i++)
		{
			int v = (ll)(F[i][k + 1] - F[i][t + 1]) * inv[n - t] % mod;
			S[l + 1] = 'a' + i - 1;
			sum = (sum + (ll)(Getkmp(S, l * 2 + 1, G, p) - s * 2) * v) % mod;
		}
		if (sum < 0)
			sum += mod;
		printf("%d\n", sum);
	}
}