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 <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define setIO(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
#define closefile fclose(stdin), fclose(stdout)
#define m_p make_pair
#define sz(x) (int)x.size()
#define see(x) cerr << x << " "
#define seeln(x) cerr << x << endl
#define out(x) cerr << #x << " = " << x << " "
#define outln(x) cerr << #x << " = " << x << endl
#define outarr(x, l, r) {cerr<< #x"[" << l << " ~ " << r << "] = "; for (int _i = l; _i <= r; ++_i) cerr << x[_i] << " "; cerr << endl;}
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define gc() getchar()
//#define gc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
char buf[1 << 21], *p1 = buf, *p2 = buf;
template <class T> void read(T &x)
{
    x = 0; int c = gc(); int flag = 0;
    while (c < '0' || c > '9') flag |= (c == '-'), c = gc();
    while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) +(c ^ 48), c = gc();
    if (flag) x = -x;
}
template <class T> T _max(T a, T b){return b < a ? a : b;}
template <class T> T _min(T a, T b){return a < b ? a : b;}
template <class T> bool checkmax(T &a, T b){return a < b ? a = b, 1 : 0;}
template <class T> bool checkmin(T &a, T b){return b < a ? a = b, 1 : 0;}
const int N = 400005, M = 1000005, mod = 1000000000 + 7, inv2 = (mod + 1) / 2;
void add(int &a, int b){a += b; (a >= mod) && (a -= mod);}
void sub(int &a, int b){a -= b; (a < 0) && (a += mod);}
void mul(int &a, int b){a = (ll)a * b % mod;}
int Add(int a, int b){a += b; return a >= mod ? a - mod : a;}
int Sub(int a, int b){a -= b; return a < 0 ? a + mod : a;}
int Mul(int a, int b){return (ll)a * b % mod;}
int qpow(int a, int b){int ans = 1; while (b) {if (b & 1) ans = (ll)ans * a % mod; a = (ll)a * a % mod; b >>= 1;} return ans;}

char t[N], b[M];
string s0;
int n, q, m;
int csp[M];
int g[26];
int pw2[M], ipw2[M];
int suf[N][26];
int hcy = 0;
void init()
{
	read(n); read(q);
	char tmp[104];
	scanf("%s%s", tmp, t + 1);
	s0 = tmp;
	pw2[0] = 1; for (int i = 1; i <= 1000000; ++i) pw2[i] = 2LL * pw2[i - 1] % mod;
	ipw2[0] = 1; for (int i = 1; i <= 1000000; ++i) ipw2[i] = (ll)inv2 * ipw2[i - 1] % mod;
	for (int i = 1; i <= n; ++i)
	{
		memcpy(suf[i], suf[i - 1], sizeof suf[i]);
		add(suf[i][t[i] - 'a'], ipw2[i]);
	}
}

void get_csp(char *s, int n)
{
	int i = 1, j = 0;
	for (; i < n; ++i)
	{
		while (j && s[i] != s[j]) j = csp[j - 1];
		if (s[i] == s[j]) ++j, csp[i] = j;
		else csp[i] = 0;
	}
}

int kmp(string s, char *t, int n, int m)
{
	int i = 0, j = 0, occ = 0;
	for (; i < n; ++i)
	{
		while (j && s[i] != t[j]) j = csp[j - 1];
		if (s[i] == t[j]) ++j;
		if (j == m)
		{
			++occ;
			j = csp[j - 1];
		}
	}
	return occ;
}

int calc(int k)
{
	string s = s0; int now = 1;
	if (sz(s0) < m)
	{
		for (int i = 1; i < k; ++i) 
		{
			s = s + t[i] + s;
			if (sz(s) >= m) {now = i + 1; break;}
		}
	}
	int w = sz(s);
	if (w < m) return 0;
	get_csp(b, m);
	int F = kmp(s, b, w, m);
	if (k < now) return F;
	string ss = s.substr(sz(s) - m + 1) + '0' + s.substr(0, m - 1);
	for (int i = 0; i < 26; ++i)
	{
		ss[m - 1] = 'a' + i;
		g[i] = kmp(ss, b, m + m - 1, m);
	}
	mul(F, pw2[k - now]);
	int o = 0;
	for (int i = 0; i < 26; ++i)
	{
		add(o, Mul(g[i], Sub(suf[k - 1][i], suf[now - 1][i])));
	}
	add(F, Mul(o, pw2[k - 1]));
	return F;
}

void solve()
{
	int k;
	vector<int> v;
	for (int i = 1; i <= q; ++i)
	{ 
		read(k); ++k; scanf("%s", b);
		m = strlen(b);
		printf("%d\n", calc(k));
	}
}

int main()
{
	//setIO("");
	init();
	solve();
	return 0;
}