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;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

template <long long mod>
struct modular {
    long long value;
    modular(long long x = 0) {
        value = x % mod;
        if (value < 0) value += mod;
    }
    modular& operator+=(modular other) {
        if ((value += other.value) >= mod) value -= mod;
        return *this;
    }
    modular& operator-=(modular other) {
        if ((value -= other.value) < 0) value += mod;
        return *this;
    }
    modular& operator*=(modular other) {
        value = value * other.value % mod;
        return *this;
    }
    modular& operator/=(modular other) {
        long long a = 0, b = 1, c = other.value, m = mod;
        while (c != 0) {
            long long t = m / c;
            m -= t * c;
            swap(c, m);
            a -= t * b;
            swap(a, b);
        }
        a %= mod;
        if (a < 0) a += mod;
        value = value * a % mod;
        return *this;
    }
    modular operator-() { return modular(-value); }
    modular operator+(modular rhs) { return modular(*this) += rhs; }
    modular operator-(modular rhs) { return modular(*this) -= rhs; }
    modular operator*(modular rhs) { return modular(*this) *= rhs; }
    modular operator/(modular rhs) { return modular(*this) /= rhs; }
    bool operator==(modular rhs) { return value == rhs.value; }
    bool operator!=(modular rhs) { return value != rhs.value; }
    bool operator<(modular rhs) { return value < rhs.value; }
};
template <long long mod>
string to_string(modular<mod> x) {
    return to_string(x.value);
}
template <long long mod>
ostream& operator<<(ostream& stream, modular<mod> x) {
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream << x.value;
}
template <long long mod>
istream& operator>>(istream& stream, modular<mod>& x) {
    stream >> x.value;
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream;
}
const long long mod = (long long)1e9 + 7;
using mint = modular<mod>;

inline mint pw(mint a, long long n) {
    mint res = 1;
    while (n > 0) {
        if (n & 1) {
            res *= a;
        }
        a *= a;
        n >>= 1;
    }
    return res;
}
vector<mint> fact(1, 1), finv(1, 1);
inline mint C(int n, int k) {
    if (n < k || k < 0) {
        return mint(0);
    }
    while ((int)fact.size() < n + 1) {
        fact.emplace_back(fact.back() * (int)fact.size());
        finv.emplace_back(mint(1) / fact.back());
    }
    return fact[n] * finv[k] * finv[n - k];
}

vector<int> z_algo(const string& s) {
    int n = (int)s.size();
    vector<int> res(n, n);
    int l = 0, r = 0;
    for (int i = 1; i < n; i++) {
        res[i] = (r < i ? 0 : min(r - i + 1, res[i - l]));
        while (i + res[i] < n && s[res[i]] == s[i + res[i]]) {
            res[i]++;
        }
        if (r < i + res[i] - 1) {
            l = i;
            r = i + res[i] - 1;
        }
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    string s0, t;
    cin >> s0 >> t;
    vector<string> s(n + 1);
    s[0] = s0;
    for (int i = 1; i <= n; i++) {
        s[i] = s[i - 1] + t[i - 1] + s[i - 1];
        if ((int)s[i].size() > (int)1e6) {
            break;
        }
    }
    int MAX = (int)2.1e6;
    vector<mint> p2(MAX, 1);
    for (int i = 1; i < MAX; i++) {
        p2[i] = p2[i - 1] * 2;
    }
    vector<vector<mint>> b(n + 1, vector<mint>(26));
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 26; j++) {
            b[i][j] = b[i - 1][j];
        }
        b[i][t[i - 1] - 'a'] += mint(1) / p2[i];
    }
    while (q--) {
        int k;
        string w;
        cin >> k >> w;
        int id = 0;
        while (s[id].size() < w.size()) {
            id++;
        }
        if (id > k) {
            cout << 0 << '\n';
            continue;
        }
        vector<int> f = z_algo(w + "#" + s[id]);
        vector<int> g = z_algo(string(w.rbegin(), w.rend()) + "#" + string(s[id].rbegin(), s[id].rend()));
        int m = (int)w.size();
        int l = (int)f.size();
        mint ans = 0;
        for (int i = m + 1; i < l; i++) {
            if (f[i] == m) {
                ans += p2[k - id];
            }
        }
        vector<int> a(26);
        for (int i = 0; i < m; i++) {
            bool ok = true;
            if (i != 0) {
                if (f[l - i] != i) {
                    ok = false;
                }
            }
            if (i != m - 1) {
                if (g[l - (m - 1 - i)] != m - 1 - i) {
                    ok = false;
                }
            }
            if (ok) {
                a[w[i] - 'a']++;
            }
        }
        mint tmp = 0;
        for (int i = 0; i < 26; i++) {
            tmp += (b[k][i] - b[id][i]) * a[i];
        }
        ans += tmp * p2[k];
        cout << ans << '\n';
    }
    return 0;
}