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 pii = std::pair <int, int>;

std::vector<pii> pbs;

struct Hash{
    int moder, base;
    std::vector <int> power;
    std::vector <int> hash;

    Hash(int moder, int base, const char *s, int n):moder(moder), base(base), power(n + 1), hash(n + 1){
        hash[0] = 0, power[0] = 1;
        for (int i = 1; i <= n; ++ i){
            hash[i] = (1ll * base * hash[i - 1] + s[i - 1]) % moder;
            power[i] = 1ll * power[i - 1] * base % moder;
        }
    }

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

struct Hasher{
    std::vector<Hash> hashes1, hashes2;

    Hasher(const std::vector<pii> &pbs, char *s, char *t){
        int n = strlen(s), m = strlen(t);
        for (auto pb : pbs){
            hashes1.emplace_back(pb.first, pb.second, s, n);
            hashes2.emplace_back(pb.first, pb.second, t, m);
        }
    }

    bool query(int l1, int r1, int l2, int r2){
        int sz = hashes1.size();
        for (int i = 0; i < sz; ++ i){
            if (hashes1[i].query(l1, r1) != hashes2[i].query(l2, r2)){
                return false;
            }
        }
        return true;
    }
};

const int N = 2000010;
const int M = 100010;
const int K = 30;
const int moder = int(1e9) + 7;

char s[N], t[N];
char tmp[N], query[N];
bool prefix[N], suffix[N];
int pref[M][K];
int power[N];

int build(){
    Hasher hasher(pbs, tmp, query);
    int n = strlen(tmp);
    int m = strlen(query);
    int cnt = 0;
    for (int i = 0; i < n; ++ i){
        int r = i + m - 1;
        if (r >= n){
            break;
        }
        cnt += hasher.query(i, r, 0, m - 1);
    }
    prefix[0] = suffix[0] = true;
    for (int i = 1; i <= m; ++ i){
        int l1 = 0, r1 = i - 1;
        int l2 = m - i, r2 = m - 1;
        suffix[i] = hasher.query(l1, r1, l2, r2);
        l1 = n - i, r1 = n - 1;
        l2 = 0, r2 = i - 1;
        prefix[i] = hasher.query(l1, r1, l2, r2);
    }
    return cnt;
}

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

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

    std::vector<int> bases = {
        37,
        41,
        43,
        47,
        53,
        59,
        61,
        67,
        71,
        73,
        79,
        83,
        89,
        97,
        101,
        103,
    };

    std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
    std::shuffle(primes.begin(), primes.end(), rnd);
    std::shuffle(bases.begin(), bases.end(), rnd);

    pbs = {{primes[0], bases[0]}, {primes[1], bases[1]}};

    power[0] = 1;
    for (int i = 1; i < N; ++ i){
        power[i] = 2 * power[i - 1] % moder;
    }

    int n, q;
    scanf("%d%d", &n, &q);
    scanf("%s%s", s, t);
    int lent = strlen(t);
    for (int i = 0; i < lent; ++ i){
        for (int j = 0; j < K; ++ j){
            pref[i + 1][j] = 2ll * pref[i][j] % moder;
        }
        add(pref[i + 1][t[i] - 'a'], 1);
    }
    while (q --){
        int end;
        scanf("%d%s", &end, query);
        int m = strlen(query);
        std::string str = s;
        int 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());
        int cnt = build();
        int ans = 1ll * power[end - cur] * cnt % moder;
        for (int i = 0; i < m; ++ i){
            if (prefix[i] && suffix[m - 1 - i]){
                int value = (pref[end][query[i] - 'a'] - 1ll * power[end - cur] * pref[cur][query[i] - 'a']) % moder;
                value += value < 0 ? moder : 0;
                add(ans, value);
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

/*
4 1
aba
bbac
3 ab

2 7
a
bc
2 a
2 b
2 c
2 ab
2 ba
2 aca
1 aca

1 4
awag
t
0 a
0 b
0 w
0 g

7 1
cabbcac
cabccca
7 acb
 */