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;

const int M = 1000000007;
struct mint {

  int val = 0;

  mint() {}

  mint(int a) : val(a) {
    while (val < 0) {
      val += M;
    }
    while (val >= M) {
      val -= M;
    }
  }

  mint(long long a) : val(a % M) {
    if (val < 0) {
      val += M;
    }
  }

  mint operator+=(mint oth) {
    val += oth.val;
    val -= (val >= M) ? M : 0;
    return *this;
  }

  mint operator-=(mint oth) {
    val -= oth.val;
    val += (val < 0) ? M : 0;
    return *this;
  }

  mint operator*=(mint oth) {
    val = 1LL * val * oth.val % M;
    return *this;
  }

  void operator++() {
    ++val;
    if (val == M) {
      val = 0;
    }
  }

  void operator--() {
    --val;
    if (val == -1) {
      val = M - 1;
    }
  }

  mint operator-() {
    mint res;
    res.val = (val == 0) ? 0 : M - val;
    return res;
  }

  friend mint operator+(mint a, mint b) {
    return mint(a) += b;
  }

  friend mint operator-(mint a, mint b) {
    return mint(a) -= b;
  }

  friend mint operator*(mint a, mint b) {
    return mint(a) *= b;
  }

  friend bool operator==(mint a, mint b) {
    return a.val == b.val;
  }

  friend bool operator!=(mint a, mint b) {
    return a.val != b.val;
  }

  friend ostream& operator<<(ostream &out, mint a) {
    out << a.val;
    return out;
  }

  friend mint pow(mint b, long long e = M - 2) {
    mint res = 1;
    while (e > 0) {
      if (e % 2 == 1) {
        res *= b;
      }
      b *= b;
      e /= 2;
    }
    return res;
  }

};

template <class T>
struct fenwick {

  vector<T> tree;
  int n;

  fenwick(int n) : n(n) {
    tree.resize(n + 1);
  }

  void update(int a, T val) {
    for ( ; a <= n; a += a & -a) {
      tree[a] += val;
    }
  }

  T query(int a) {
    T res = 0;
    for ( ; a > 0; a -= a & -a) {
      res += tree[a];
    }
    return res;
  }

  T query(int a, int b) {
    return query(b) - query(a - 1);
  }

  int lower_bound(T k) {
    int res = 0;
    T cur = 0;
    for (int i = 31 - __builtin_clz(n); i >= 0; --i) {
      if (res + (1 << i) <= n && cur + tree[res + (1 << i)] < k) {
        res += 1 << i;
        cur += tree[res];
      }
    }
    return res + 1;
  }

};

const int K = 1000000 + 1;

mt19937 rng((unsigned long long) new char);
mint base = uniform_int_distribution<int>(137, M - 1)(rng);
mint pow_base[3 * K];
mint inv_base[3 * K];

void init_hash() {
  mint inv = pow(base);
  pow_base[0] = 1;
  inv_base[0] = 1;
  for (int j = 1; j < 3 * K; ++j) {
    pow_base[j] = pow_base[j - 1] * base;
    inv_base[j] = inv_base[j - 1] * inv;
  }
}

struct poly_hash {

  vector<mint> prefix;

  poly_hash() {}

  poly_hash(const string& s) {
    int n = s.size();
    prefix.resize(n + 1);
    for (int j = 0; j < n; ++j) {
      prefix[j + 1] = prefix[j] + s[j] * pow_base[j];
    }
  }

  mint query(int a, int b) {
    return (prefix[b] - prefix[a - 1]) * inv_base[a - 1];
  }

};

const int N = 100000;
const int A = 26;

int in[K], out[K], to[K][A], link[K], timer, m = 1;
vector<int> adj[K];

void dfs(int u) {
  in[u] = ++timer;
  for (auto c : adj[u]) {
    dfs(c);
  }
  out[u] = timer;
}

int song[N], indices[N], tail[N];
mint freq[A], ans[N];
string name[N];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  init_hash();

  int n, q;
  string s, t;
  cin >> n >> q >> s >> t;

  for (int i = 0; i < q; ++i) {
    cin >> song[i] >> name[i];
    for (auto c : name[i]) {
      if (to[tail[i]][c - 'a'] == 0) {
        to[tail[i]][c - 'a'] = m++;
      }
      tail[i] = to[tail[i]][c - 'a'];
    }
  }

  queue<int> que;
  que.push(0);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    if (u != link[u]) {
      adj[link[u]].push_back(u);
    }
    for (int i = 0; i < A; ++i) {
      if (to[u][i] == 0) {
        to[u][i] = to[link[u]][i];
      } else {
        link[to[u][i]] = (u == 0) ? 0 : to[link[u]][i];
        que.push(to[u][i]);
      }
    }
  }

  dfs(0);

  fenwick<mint> fenw(m);

  iota(indices, indices + q, 0);
  sort(indices, indices + q, [&](int a, int b) {
    return song[a] < song[b];
  });

  int u = 0, j = 0;
  poly_hash hash_s;
  mint coeff = 1;

  for (int i = 0; i <= n; ++i) {
    if (i == 0) {
      for (auto c : s) {
        u = to[u][c - 'a'];
        fenw.update(in[u], 1);
      }
    } else {
      if ((int) s.size() <= K) {
        u = to[u][t[i - 1] - 'a'];
        fenw.update(in[u], 1);
        for (auto c : s) {
          u = to[u][c - 'a'];
          fenw.update(in[u], 1);
        }
        s += t[i - 1] + s;

        if ((int) s.size() > K) {
          hash_s = poly_hash(s);
        }
      } else {
        coeff *= 2;
        for (int j = 0; j < A; ++j) {
          freq[j] = 2 * freq[j] + (t[i - 1] - 'a' == j);
        }
      }
    }

    for ( ; j < q && song[indices[j]] == i; ++j) {
      int k = indices[j];
      ans[k] = fenw.query(in[tail[k]], out[tail[k]]) * coeff;
      if ((int) s.size() > K) {
        poly_hash hash_k(name[k]);
        for (int l = 0; l < (int) name[k].size(); ++l) {
          if (l > 0 &&
              hash_s.query(s.size() - l + 1, s.size()) != hash_k.query(1, l)) {
            continue;
          }
          if (l < (int) name[k].size() - 1 &&
              hash_s.query(1, name[k].size() - l - 1) != hash_k.query(l + 2, name[k].size())) {
            continue;
          }
          ans[k] += freq[name[k][l] - 'a'];
        }
      }
    }
  }

  for (int i = 0; i < q; ++i) {
    cout << ans[i] << "\n";
  }
}