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 ll = long long;
const ll N = 2000010;
const ll M = 100010;
const ll mod = ll(1e9) + 7;

std::vector<ll> primes = {
    1001452733,
    1001452759,
    1001452787,
    1001452789,
    1001452871,
    1001452897,
    1001452937,
    1001452957,
    1001452981,
    1001452993,
    1001452999,
    1001453021,
    1001453029,
    1001453041,
    1001453069,
    1001453081
};

char s[N], t[N];
char tmp[N], query[N];
bool prefix[N], suffix[N];

struct Hash{
    ll moder, base;
    ll power[N];
    ll hash[N];

    ll powermod(ll a, ll exp){
        ll ret = 1;
        for ( ; exp > 0; exp >>= 1){
            if (exp & 1){
                ret = 1ll * ret * a % moder;
            }
            a = 1ll * a * a % moder;
        }
        return ret;
    }

    void init(ll m, ll b){
        moder = m;
        base = b;
        power[0] = 1;
        power[1] = b;
        for (ll i = 1; i < N; ++ i){
            power[i] = 1ll * power[i - 1] * power[1] % moder;
        }
    }

    void calc(char *s){
        ll n = strlen(s);
        hash[0] = 0;
        for (ll i = 1; i <= n; ++ i){
            hash[i] = (1ll * base * hash[i - 1] + s[i - 1] - 'a') % moder;
        }
    }

    ll query(ll l, ll r){
        ll ret = (hash[r + 1] - 1ll * power[r - l + 1] * hash[l]) % moder;
        ret += ret < 0 ? moder : 0;
        return ret;
    }
};

Hash hash1, hash2, hash3, hash4;

bool check(ll l1, ll r1, ll l2, ll r2){
    if (hash1.query(l1, r1) != hash2.query(l2, r2)){
        // prllf("%d %d %d %d %d %d\n", l1, r1, l2, r2, hash1.query(l1, r1), hash2.query(l2, r2));
        return false;
    }
    if (hash3.query(l1, r1) != hash4.query(l2, r2)){
        return false;
    }
    return true;
}

ll build(){
    hash1.calc(tmp);
    hash3.calc(tmp);
    hash2.calc(query);
    hash4.calc(query);
    ll n = strlen(tmp);
    ll m = strlen(query);
    ll cnt = 0;
    for (ll i = 0; i < n; ++ i){
        ll r = i + m - 1;
        if (r >= n){
            break;
        }
        if (check(i, r, 0, m - 1)){
            ++ cnt;
        }
    }
    prefix[0] = suffix[0] = true;
    for (ll i = 1; i <= m; ++ i){
        ll l1 = 0, r1 = i - 1;
        ll l2 = m - i, r2 = m - 1;
        suffix[i] = check(l1, r1, l2, r2);
        l1 = n - i, r1 = n - 1;
        l2 = 0, r2 = i - 1;
        prefix[i] = check(l1, r1, l2, r2);
    }
    return cnt;
}

const ll BASE1 = 37;
const ll BASE2 = 73;

ll pref[M][BASE1];
ll power[N], ipower[N];

ll powermod(ll a, ll exp){
    ll ret = 1;
    for ( ; exp > 0; exp >>= 1){
        if (exp & 1){
            ret = 1ll * ret * a % mod;
        }
        a = 1ll * a * a % mod;
    }
    return ret;
}

void add(ll &u, ll v){
    u += v;
    u -= u >= mod ? mod : 0;
}

/*ll bf(std::string s1, std::string s2){
    ll n = s1.size(), m = s2.size();
    ll cnt = 0;
    for (ll i = 0; i <= n - m; ++ i){
        if (s1.substr(i, m) == s2){
            ++ cnt;
        }
    }
    return cnt;
}*/

int main(){
    ll moder1, moder2;
    /*for (ll i = 1001010100; i < 2e9; ++ i){
        bool flag = true;
        for (ll j = 2; j * j <= i; ++ j){
            if (i % j == 0){
                flag = false;
                break;
            }
        }
        if (flag){
            prllf("%d\n", i);
            fflush(stdout);
        }
    }*/
    power[0] = ipower[0] = 1;
    power[1] = 2;
    ipower[1] = powermod(2, mod - 2);
    for (ll i = 1; i < N; ++ i){
        power[i] = 1ll * power[i - 1] * power[1] % mod;
        ipower[i] = 1ll * ipower[i - 1] * ipower[1] % mod;
    }
    std::mt19937 rnd(std::chrono::steady_clock().now().time_since_epoch().count());
    moder1 = primes[rnd() % primes.size()];
    while (true){
        moder2 = primes[rnd() % primes.size()];
        if (moder1 != moder2){
            break;
        }
    }
    hash1.init(moder1, BASE1);
    hash2.init(moder1, BASE1);
    hash3.init(moder2, BASE2);
    hash4.init(moder2, BASE2);
    ll n, q;
    scanf("%lld%lld", &n, &q);
    scanf("%s%s", s, t);
    // for (ll i = 0; i < n; ++ i){
    //     s[i] = rnd() % 3 + 'a';
    //     t[i] = rnd() % 3 + 'a';
    // }
    ll lent = strlen(t);
    for (ll i = 0; i < lent; ++ i){
        for (ll j = 0; j < BASE1; ++ j){
            pref[i + 1][j] = 2ll * pref[i][j] % mod;
        }
        add(pref[i + 1][t[i] - 'a'], 1);
    }
    while (q --){
        ll end;
        scanf("%lld%s", &end, query);
        // end = n;
        // for (ll i = 0; i < 3; ++ i){
        //     query[i] = rnd() % 3 + 'a';
        // }
        ll m = strlen(query);
        std::string str = s;
        ll cur = 0;
        while (cur < end && str.size() < m){
            str += t[cur] + str;
            ++ cur;
        }
        if (str.size() < m){
            puts("0");
            continue;
        }
        strcpy(tmp, str.c_str());
        ll cnt = build();
        ll ans = 1ll * power[end - cur] * cnt % mod;
        for (ll i = 0; i < m; ++ i){
            if (prefix[i] && suffix[m - 1 - i]){
                ll value = (pref[end][query[i] - 'a'] - 1ll * power[end - cur] * pref[cur][query[i] - 'a']) % mod;
                value += ans < 0 ? mod : 0;
                add(ans, value);
            }
        }
        ans = (ans % mod + mod) % mod;
        printf("%lld\n", ans);
        /*std::string tmp = s;
        for (ll i = 0; i < end; ++ i){
            tmp += t[i] + tmp;
        }
        //prllf("%d\n", bf(tmp, query));
        if (ans != bf(tmp, query)){
            puts("-----");
            puts(s);
            puts(t);
            prllf("%d %s\n", end, query);
            exit(0);
        }*/
    }
    return 0;
}