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;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
using ld = long double;
using dbl = double;
template<typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template<typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }
void debug_out()
{
    cerr << endl;
}
template<typename T1, typename... T2> void debug_out(T1 A, T2... B)
{
    cerr << ' ' << A;
    debug_out(B...);
}
#ifdef DEBUG
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1337
#endif

const int MOD = 1e9 + 7;
int add(int a, int b)
{
    a += b;
    if (a >= MOD)
        a -= MOD;
    return a;
}
void vadd(int &a, int b)
{
    a += b;
    if (a >= MOD)
        a -= MOD;
}
int sub(int a, int b)
{
    a -= b;
    if (a < 0)
        a += MOD;
    return a;
}
void vsub(int &a, int b)
{
    a -= b;
    if (a < 0)
        a += MOD;
}
int mult(int a, int b)
{
    return a * (ll)b % MOD;
}

const int maxN = 100005;
int p2[maxN];
const int maxM = 102;
int N, M, Q;
char s0[maxM];
char t[maxN];
int dp[26][maxN];

int solve(string w, int l, int k)
{
    if (w.size() == 1)
    {
        int ans = dp[w[0] - 'a'][k];
        if (l > 0)
            vsub(ans, mult(p2[k - (l - 1)], dp[w[0] - 'a'][l - 1]));
//        debug(w, l, k, ans);
        return ans;
    }
    if (k < 24 && w.size() > ((1 << k) - 1))
        return 0;

    int ans = 0;
    for (int r = 0; r < 2; ++r)
    {
        bool bad = false;
        for (int i = r; i < w.size(); i += 2)
        {
            if (w[i] != t[l - 1])
            {
                bad = true;
                break;
            }
        }
        if (bad) continue;
        string new_w = "";
        for (int i = (r ^ 1); i < w.size(); i += 2)
        {
            new_w += w[i];
        }
        vadd(ans, solve(new_w, l + 1, k));
    }
//    debug(w, l, k, ans);
    return ans;
}

signed main()
{
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);

    p2[0] = 1;
    for (int i = 1; i < maxN; ++i)
        p2[i] = mult(2, p2[i - 1]);

    cin >> N >> Q >> s0 >> t;
    M = strlen(s0);
    for (int k = 1; k <= N; ++k)
    {
        for (int c = 0; c < 26; ++c)
            dp[c][k] = mult(2, dp[c][k - 1]);
        vadd(dp[t[k - 1] - 'a'][k], 1);
    }
    while (Q--)
    {
        int k;
        cin >> k;
        string w;
        cin >> w;
        int ans = 0;
        for (int r = 0; r <= M; ++r)
        {
            string e = "";
            bool bad = false;
            for (int i = 0, cur = r; i < w.size(); ++i)
            {
                if (cur == M)
                {
                    e += w[i];
                    cur = 0;
                }
                else
                {
                    if (s0[cur] != w[i])
                    {
                        bad = true;
                        break;
                    }
                    ++cur;
                }
            }
            if (!bad)
            {
                if (!e.empty())
                    vadd(ans, solve(e, 1, k));
                else
                    vadd(ans, p2[k]);
            }
        }
        cout << ans << '\n';
    }

    return 0;
}