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;
const int mod = 1000000007;
const int mod2 = 1000000009;
const int base = 13131;
const int base2 = 1313131;
int n, q, m, l, song;
int f[100020][26];
char t[100020];
int pw2[100020];
char s[100020];
int sh1[100020];
int sh2[100020];
char w[1000020];
int pwh1[1000020];
int pwh2[1000020];
int wh1[1000020];
int wh2[1000020];
long long z;
void gao(int b, int k, int d)
{
	if (d > song)
	{
		return;
	}
	if (b >= l)
	{
		z = (z + pw2[song - d]) % mod;
		return;
	}
	// printf("gao %d %d %d\n", b, k, d);
	if (b + k >= l)
	{
		// printf("%d %d\n", b, l);
		// assert(0 <= b && b < l);
		// for (int i = d; i < song; i++)
		// {
		// 	if (t[i] == w[b])
		// 	{
		// 		z = (z + pw2[song - 1 - i]) % mod;
		// 	}
		// }
		z = (z + f[song][w[b] - 'a'] + mod - (long long)pw2[song - d] * f[d][w[b] - 'a'] % mod) % mod;
		return;
	}
	if (d >= n)
	{
		return;
	}
	bool even = true;
	for (int i = b; i < l; i += k * 2)
	{
		if (w[i] != t[d])
		{
			even = false;
			break;
		}
	}
	if (even)
	{
		gao(b + k, k * 2, d + 1);
	}
	bool odd = true;
	for (int i = b + k; i < l; i += k * 2)
	{
		if (w[i] != t[d])
		{
			odd = false;
			break;
		}
	}
	if (odd)
	{
		gao(b, k * 2, d + 1);
	}
}
bool eq(int ws, int ss, int len)
{
	int we = ws + len;
	int se = ss + len;
	if ((wh1[we] + mod - (long long)wh1[ws] * pwh1[len] % mod) % mod != (sh1[se] + mod - (long long)sh1[ss] * pwh1[len] % mod) % mod)
	{
		return false;
	}
	if ((wh2[we] + mod2 - (long long)wh2[ws] * pwh2[len] % mod2) % mod2 != (sh2[se] + mod2 - (long long)sh2[ss] * pwh2[len] % mod2) % mod2)
	{
		return false;
	}
	return true;
}
bool ok(int i)
{
	for (int j = 0; j < l;)
	{
		if ((j + m - i) % (m + 1) == m)
		{
			j++;
		}
		else
		{
			int st = (j + m - i) % (m + 1);
			int len = min(m - st, l - j);
			 // w[j, j + l) =?= s[st, st + len)
			if (!eq(j, st, len))
			{
				return false;
			}
			j += len;
			// if (w[j] != s[(j + m - i) % (m + 1)])
			// {
			// 	return false;
			// }
			// j++;
		}
	}
	return true;
}
int main()
{
	for (int i = pw2[0] = 1; i < 100010; i++)
	{
		pw2[i] = pw2[i - 1] * 2 % mod;
	}
	for (int i = pwh1[0] = 1; i < 1000010; i++)
	{
		pwh1[i] = (long long)pwh1[i - 1] * base % mod;
	}
	for (int i = pwh2[0] = 1; i < 1000010; i++)
	{
		pwh2[i] = (long long)pwh2[i - 1] * base2 % mod2;
	}
	scanf("%d%d", &n, &q);
	scanf("%s", s);
	scanf("%s", t);
	m = strlen(s);
	for (int i = 0; i < m; i++)
	{
		sh1[i + 1] = ((long long)sh1[i] * base + s[i]) % mod;
	}
	for (int i = 0; i < m; i++)
	{
		sh2[i + 1] = ((long long)sh2[i] * base2 + s[i]) % mod2;
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 26; j++)
		{
			f[i + 1][j] = f[i][j] * 2 % mod;
		}
		f[i + 1][t[i] - 'a']++;
	}
	for (int qq = 0; qq < q; qq++)
	{
		scanf("%d%s", &song, w);
		l = strlen(w);
		for (int i = 0; i < l; i++)
		{
			wh1[i + 1] = ((long long)wh1[i] * base + w[i]) % mod;
		}
		for (int i = 0; i < l; i++)
		{
			wh2[i + 1] = ((long long)wh2[i] * base2 + w[i]) % mod2;
		}
		z = 0;
		// printf("%s\n", w);
		for (int i = 0; i <= m; i++)
		{
			if (ok(i))
			{
				// printf("qq=%d i=%d\n", qq, i);
				// ac = 0;
				// for (int j = i; j < l; j += m + 1)
				// {
				// 	a[ac++] = w[j];
				// }
				gao(i, m + 1, 0);
			}
		}
		printf("%lld\n", z);
	}
	return 0;
}