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<iostream>
#include<iomanip>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<utility>
#include<algorithm>
#include<cmath>


using namespace std;


typedef long long int lli;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef pair<int, int> pii;
typedef vector<int> vi;



const int MAXL = 25;
const int MAXW = 1000001;
const int ALPHABET = 26;
const lli MOD = 1000000007ll;


int N, Q, K;
string T, W;
string S[MAXL];
lli twoPow[MAXW];
lli preSum[ALPHABET][MAXW];


vi pi(const string& s) {
    vi p(sz(s));
    rep(i,1,sz(s)) {
        int g = p[i-1];
        while (g && s[i] != s[g]) g = p[g-1];
        p[i] = g + (s[i] == s[g]);
    }
    return p;
}

int match(const string& s, const string& pat) {
    vi p = pi(pat + '\0' + s), res;
    int ret = 0;
    rep(i,sz(p)-sz(s),sz(p))
        if (p[i] == sz(pat)) ret++;
    return ret;
}


void solve() {

    int initPoint = 0;
    while ((int)S[initPoint].size() < (int)W.size()) {
        initPoint++;
    }

    if (initPoint > K) {
        cout << "0\n";
        return;
    }

    //cerr << "\nINIT STRING = " << S[initPoint] << "\n";

    set<int> middle_pref;
    set<int> middle_suf;

    {
        string s_pref = W + "$" + S[initPoint];
        vi pi_pref = pi(s_pref);
        int at = (int)s_pref.size();
        at = pi_pref[at-1];
        while (at > 0) {
            middle_pref.insert(at);
            at = pi_pref[at-1];
        }
        middle_pref.insert(at);
    }

    {
        string s_suf = S[initPoint] + "$" + W;
        vi pi_suf = pi(s_suf);
        int at = (int)s_suf.size();
        at = pi_suf[at-1];
        while (at > 0) {
            middle_suf.insert(at);
            at = pi_suf[at-1];
        }
        middle_suf.insert(at);
    }

    lli ans = ((lli)match(S[initPoint], W) * twoPow[K-initPoint]) % MOD;

    //cerr << "\n\nPRINTING pref\n";
    for (auto pref : middle_pref) {
        //cerr << pref << "\n";
        if (middle_suf.count((int)W.size() - pref - 1) == 0) {
            continue;
        }

        char ch = W[pref];

        lli subtract = ((preSum[(int)(ch-'a')][initPoint] * twoPow[K-initPoint]) % MOD);
        lli add = preSum[(int)(ch-'a')][K]; 
        ans = (((ans + add - subtract) % MOD) + MOD) % MOD;
    }

    cout << ans << "\n";
}


int main() {

    ios::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0); 
    cerr.tie(0); 


    cin >> N >> Q;
    cin >> S[0] >> T;

    {
        int i = 0;
        while ((int)S[i].size() < MAXW) {
            S[i+1] = S[i] + T[i] + S[i];
            i++;
        }
    }

    {
        twoPow[0] = 1;
        for (int i = 1 ; i < MAXW ; i++) {
            twoPow[i] = (twoPow[i-1]*2) % MOD;
        }

        for(int i = 0 ; i  < ALPHABET ; i++) {
            for (int j = 1 ; j <= N ; j++) {
                preSum[i][j] = (preSum[i][j-1]*2) % MOD;
                if (T[j-1] == (char)((int)('a')+i)) {
                    preSum[i][j] = (preSum[i][j]+1) % MOD; 
                }
            }
        }
    }

    for (int q = 1 ; q <= Q; q++) {
        cin >> K >> W;
        solve();
    }



    



    return 0;
}