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 P = 1e9 + 7; int N , Q; string s0 , t; int cnt[100003][26] , iv[100003];

int main(){
	ios::sync_with_stdio(0); cin >> N >> Q >> s0 >> t; int tms = 1;
	for(int i = N - 1 ; ~i ; --i , tms = 2 * tms % P){memcpy(cnt[i] , cnt[i + 1] , sizeof(cnt[i])); cnt[i][t[i] - 'a'] = (cnt[i][t[i] - 'a'] + tms) % P;}
	iv[0] = 1; for(int i = 1 ; i <= 1e5 ; ++i) iv[i] = 1ll * iv[i - 1] * ((P + 1) / 2) % P;
	
	while(Q--){
		int ans = 0 , c; string s; cin >> c >> s;
		for(int i = 0 ; i <= s0.size() ; ++i){
			int plc = i; vector < int > matchpot; bool f = 1;
			for(int j = 0 ; f && j < s.size() ; ++j)
				if(plc == s0.size()){matchpot.push_back(s[j] - 'a'); plc = 0;} else f &= s[j] == s0[plc++];
			if(f){
				if(matchpot.empty()){ans = (ans + tms) % P; continue;}
				for(int j = 0 ; j < c ; ++j){
					if(matchpot.size() == 1){ans = (0ll + ans + cnt[j][matchpot[0]] - cnt[c][matchpot[0]] + P) % P; break;}
					bool f0 = 1 , f1 = 1; for(int k = 0 ; k < matchpot.size() ; ++k) (k & 1 ? f1 : f0) &= matchpot[k] == t[j] - 'a';
					if(f0 && f1){
						map < int , int > num; num[matchpot.size()] = 1; int vl = matchpot[0];
						while(j < c && num.size()){
							map < int , int > temp;
							for(auto t : num){
								if(t.first == 1){ans = (ans + 1ll * t.second * (cnt[j][vl] - cnt[c][vl] + P)) % P; continue;}
								temp[t.first / 2] = (temp[t.first / 2] + t.second) % P;
								temp[(t.first + 1) / 2] = (temp[(t.first + 1) / 2] + t.second) % P;
							}
							if(t[j] - 'a' != vl) break;
							++j; num = temp;
						}
						break;
					}else if(f0 || f1){
						vector < int > val; for(int k = 0 ; k < matchpot.size() ; ++k) if(f1 ^ (k & 1)) val.push_back(matchpot[k]);
						matchpot = val;
					}else break;
				}
			}
		}
		cout << 1ll * ans * iv[N - c] % P << endl;
	}
	return 0;
}