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;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, const U &b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, const U &b){ return b > a ? a = b, true : false; }

const ll mr = 1e9 + 7;
const ll MOD = 1e9 + 9, al = 31, off = 'a';
ll i_al = -1;
vector<ll> ipw;

ll exp(ll a, ll r){
    if(r == 0) return 1;
    ll tmp = exp(a, r/2);
    tmp = (tmp * tmp)%MOD;
    if(r & 1) tmp = (tmp * a)%MOD;
    return tmp;
}

void upd(int n){
    if(i_al == -1){
        i_al = exp(al, MOD - 2);
        ipw.pb(1);
    }
    while(sz(ipw) <= n) ipw.pb((ipw.back() * i_al)%MOD);
}

template<typename T> vector<ll> hsh(T &str){
    vector<ll> v(sz(str) + 1);
    upd(sz(str) + 5);
    ll nxt = 0, pw = 1;
    for(int i = 0; i < sz(str); ++i){
        v[i + 1] = (nxt + (str[i] - off + 1) * pw)%MOD;
        nxt = v[i + 1];
        pw = (pw * al)%MOD;
    }
    return v;
}

ll qry(int l, int r, vector<ll> &v){
    if(l > r || r < 0 || l < 0) return 0;
    ll res = v[r + 1] - v[l];
    return (((ipw[l] * res)%MOD) + MOD)%MOD;
}

int n, q, pos = 0;
string s0, t;
vector<ll> pw2 = {1}, pwx = {1};
vector<vector<ll>> v, amt;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> q >> s0 >> t;
    string str = s0;
    v.push_back(hsh(str));
    while(pos < n && sz(str) <= 1e6){
        str = str + t[pos++] + str;
        v.push_back(hsh(str));
    }
    for(int i = 0; i <= 1e6; ++i){
        pw2.push_back((pw2.back() << 1)%mr);
        pwx.push_back((pwx.back() * al)%MOD);
    }
    amt.assign(26, vector<ll>(n + 1, 0));
    for(int i = 0; i < n; ++i){
        ++amt[t[i] - 'a'][i + 1];
    }
    for(int j = 0; j < 26; ++j){
        for(int i = 1; i <= n; ++i){
            amt[j][i] += (amt[j][i - 1] << 1);
            amt[j][i] %= mr;
        }
    }
    while(q--){
        ll res = 0, k, r, csz; cin >> k >> str;
        for(r = sz(v) - 1; r >= 0 && sz(v[r]) - 1 >= sz(str); --r){}
        if(r != sz(v) - 1) ++r;
        ckmin(r, k);
        csz = sz(v[r]) - 1;
        if(csz < sz(str)){
            cout << "0\n";
            continue;
        }
        auto tmp = hsh(str);
        ll cur_hash = qry(0, sz(str) - 1, tmp);
        auto &ha = v[r];
        for(int i = 0; i <= csz; ++i){
            if(i + sz(str) <= csz){
                res = (res + (qry(i, i + sz(str) - 1, ha) == cur_hash) * pw2[k - r])%mr;
            }
            else{
                ll pref_hash = qry(i, csz - 1, ha), suff_hash = qry(0, sz(str) - (csz - i) - 2, ha);
                ll pref_sz = csz - i;
                for(int j = 0; j < 26; ++j){
                    ll chk = pref_hash + pwx[pref_sz] * (j + 1) + pwx[pref_sz + 1] * suff_hash;
                    chk %= MOD;
                    if(chk == cur_hash){
                        res += amt[j][k] - amt[j][r] * pw2[k - r];
                        res %= mr;
                        if(res < 0) res += mr;
                    }
                }
            }
        }
        cout << res << "\n";
    }
    return 0;
}