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>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#define F first
#define S second
#define pb push_back
#define M ll(1e9 + 7)
#define sz(x) (int)x.size()
#define re return
#define oo ll(1e18)
#define el '\n'
#define pii pair <int, int>
#define all(x) (x).begin(), (x).end()
#define arr_all(x, n) (x + 1), (x + 1 + n)
#define vi vector<int>
#define pb push_back
using namespace std;
//using namespace __gnu_pbds;
//typedef tree <int, null_type, less_equal <int> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 1e6 + 5;

vector <int> sizes;
vector <string> songs;
int k, n, m, q;
string t, s, w;
int pw[N];
int sum[30][N];

void calc_sizes()
{
    sizes.pb(sz(s));
    songs.pb(s);

    for (int i = 0; i < n; i++)
    {
        if (sizes.back() > N)
            break;

        string lst = songs.back();
        string nw = lst + t[i] + lst;

        sizes.pb(sz(nw));
        songs.pb(nw);
    }
}

vector <int> calc_kmp(string cur)
{
    vector <int> ret(sz(cur), 0);

    int j = 0;

    for (int i = 1; i < sz(cur); i++)
    {
        while (j > 0 && cur[j] != cur[i])
            j = ret[j - 1];

        if (cur[j] == cur[i])
            j++;

        ret[i] = j;
    }

    return ret;
}

vector <int> ins(vector <int> dp, int m)
{
    vector <int> ret(m + 1, 0);
    int cur = dp.back();

    while (cur)
    {
        ret[cur] = 1;
        cur = dp[cur - 1];
    }
    ret[cur] = 1;

    return ret;
}

void solve()
{
    cin >> k >> w;

    int m = sz(w);

    int id = lower_bound(all(sizes), sz(w)) - sizes.begin();

    if (id > k)
        {
            cout << "0" << el;
            return;
        }

    string aft = songs[id] + "#" + w;
    string bef = w + "#" + songs[id];

    vector <int> dp_bef = calc_kmp(bef);
    vector <int> dp_aft = calc_kmp(aft);

    vector <int> in_bef = ins(dp_bef, m);
    vector <int> in_aft = ins(dp_aft, m);

    int ans = 0;

    for (auto x : dp_bef)
        ans += (x == m);

    ans = (ans * 1ll * pw[k - id]) % M;

    for (int i = 0; i < m; i++)
    {
        if (!in_bef[i] || !in_aft[m - i - 1])
            continue;

        int c = w[i] - 'a';

        ans = (ans + sum[c][k] - sum[c][id] * 1ll * pw[k - id] + M) % M;
    }

    cout << (ans + M) % M << el;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//    in("queries.in");
//    in("input.txt");
//    out("output.txt");

    cin >> n >> q;

    cin >> s >> t;

    pw[0] = 1;
    for (int i = 1; i <= n; i++)
        pw[i] = (pw[i - 1] * 2ll) % M;

    calc_sizes();

    for (int i = 0; i < 26; i++)
    {
        char c = i + 'a';

        for (int j = 0; j < n; j++)
            sum[i][j + 1] = (sum[i][j] * 2ll + (t[j] == c)) % M;
    }

    while (q--)
        solve();
}