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:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aurinegro (Nicolás Álvarez)
 */

#include <bits/stdc++.h>
using namespace std;

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << (a) << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using ll = long long int;
using vi = vector<int>;
using pii = pair<int,int>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1e9 + 7;
const int INV2 = MOD/2 + 1;
const int M = 1e6 + 10;
const int N = 1e5 + 10;


template<class T>
vi prefix_function(const T &s) {
    int n = si(s);
    vi pi(n+1);
    pi[0] = -1;
    for (int i = 1; i <= n; i++) {
        int &p = pi[i];
        p = pi[i-1];
        while (p != -1 && s[p] != s[i-1]) p = pi[p];
        ++p;
    }
    return pi;
}

struct GSongOfTheSirens {
    const int ALPHA = 'z' - 'a' + 1;

    void solve(std::istream& cin, std::ostream& cout) {
        // read params
        int n, q;
        cin >> n >> q;

        // read srings
        vector<string> s(n+1);
        string t;
        cin >> s[0] >> t;

        // power of two and their reciprocals
        vi pot(n+1, 1), ipot(n+1, 1);
        forsn(i, 1, n+1) {
            pot[i] = 2 * pot[i-1] % MOD;
            ipot[i] = (ll) INV2 * ipot[i-1] % MOD;
        }

        // process t
        vi len(n+1);
        len[0] = si(s[0]);
        vector<vi> cum(ALPHA, vi(n+1));
        forn(i, n) {
            if (len[i] < M) {
                s[i+1] = s[i] + t[i] + s[i];
                len[i+1] = si(s[i+1]);
            }
            else len[i+1] = len[i];

            int x = t[i] - 'a';
            forn(y, ALPHA) {
                cum[y][i+1] = cum[y][i] + (x == y) * ipot[i+1];
                if (cum[y][i+1] >= MOD) cum[y][i+1] -= MOD;
            }
        }

        while (q--) {
            int k; string w;
            cin >> k >> w;
            int len_w = si(w);
            int from = lower_bound(all(len), len_w) - len.begin();

            ll ans = 0;
            if (from <= k) {
                vi pi;
                pi = prefix_function(w + "#" + s[from]);
                int matches = 0;
                for (auto x : pi) matches += x == si(w);
                ans += (ll) matches * ipot[from] % MOD;

                if (from < k) {
                    int len_w = si(w);
                    vi prefix(len_w + 1), suffix(len_w + 1);
                    for (int p = pi.back(); p != -1; p = pi[p]) prefix[p] = 1;
                    pi = prefix_function(s[from] + "#" + w);
                    for (int p = pi.back(); p != -1; p = pi[p]) suffix[p] = 1;

                    forn(l, len_w) if (prefix[l] && suffix[len_w-1-l])
                            ans += cum[w[l]-'a'][k] - cum[w[l]-'a'][from] + MOD;
                }
            }
            cout << ans % MOD * pot[k] % MOD << '\n';
        }
    }
};


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    GSongOfTheSirens solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}