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>
#ifdef LOCAL
#include "debuger.hpp"
#else
#define DUMP(...) 1145141919810
#define CHECK(...) (__VA_ARGS__)
#endif

template<int MOD>
struct Integral {
  int v_ = 0;

  Integral() {}
  template<typename T> Integral(T v) : v_(norm(v)) {  // Implicit conversion is allowed.
    static_assert(std::is_integral<T>::value, "input should be an integral.");
  }
  ~Integral() = default;

  template<typename T> T norm(T v) const {
    if (v >= MOD) v -= MOD;
    if (v < 0) v += MOD;
    if (v >= MOD || v < 0) v = (v % MOD + MOD) % MOD;
    return v;
  }

  int val() const { return v_; }
  Integral operator - () const { return Integral(-val()); }

  Integral power(long long b) const {
    long long ret = 1 % MOD, a = v_;
    for ( ; b; b >>= 1, a = a * a % MOD) if (b & 1) ret = ret * a % MOD; return ret;
  }
  Integral inv() const { return power(MOD - 2); }
};

// +
template<int MOD> inline Integral<MOD> operator + (const Integral<MOD>& lhs, const Integral<MOD>& rhs) {
  return Integral<MOD>(lhs.val() + rhs.val());
}
template<int MOD> inline Integral<MOD>& operator += (Integral<MOD>& lhs, const Integral<MOD> & rhs) {
  return lhs = lhs + rhs;
}

// -
template<int MOD> inline Integral<MOD> operator - (const Integral<MOD>& lhs, const Integral<MOD>& rhs) {
  return Integral<MOD>(lhs.val() - rhs.val());
}
template<int MOD> inline Integral<MOD>& operator -= (Integral<MOD>& lhs, const Integral<MOD>& rhs) {
  return lhs = lhs - rhs;
}

// *
template<int MOD> inline Integral<MOD> operator * (const Integral<MOD>& lhs, const Integral<MOD>& rhs) {
  return Integral<MOD>(lhs.val() * 1LL * rhs.val());
}
template<int MOD> inline Integral<MOD>& operator *= (Integral<MOD>& lhs, const Integral<MOD>& rhs) {
  return lhs = lhs * rhs;
}

// /
template<int MOD> inline Integral<MOD> operator / (const Integral<MOD>& lhs, const Integral<MOD>& rhs) {
  return lhs * rhs.inv();
}
template<int MOD> inline Integral<MOD>& operator /= (Integral<MOD>& lhs, const Integral<MOD>& rhs) {
  return lhs = lhs / rhs;
}

// ==
template<int MOD> inline bool operator == (const Integral<MOD>& lhs, const Integral<MOD>& rhs) {
  return lhs.val() == rhs.val();
}
template<int MOD> inline bool operator != (const Integral<MOD>& lhs, const Integral<MOD>& rhs) {
  return !(lhs == rhs);
}

template<int MOD>
std::string to_string(const Integral<MOD>& v) {
  return std::string("Integral{v=") + std::to_string(v.val()) + "}";
}

template<int MOD>
struct Binomial {
  std::vector<Integral<MOD>> factor, inv_factor;

  void init(int n) {
    factor.resize(n + 1);
    inv_factor.resize(n + 1);
    factor[0] = 1;
    for (int i = 1; i <= n; ++i) factor[i] = factor[i - 1] * i;
    inv_factor[n] = factor[n].inv();
    for (int i = n; i >= 1; --i) inv_factor[i - 1] = inv_factor[i] * i;
  }

  Integral<MOD> operator () (int a, int b) const {
    if (a < b || b < 0) return 0;
    if (a < factor.size()) return factor[a] * inv_factor[b] * inv_factor[a - b];
    b = std::min(b, a - b);
    Integral<MOD> ret = 1;
    for (int i = 1; i <= b; ++i) ret = ret * (a + 1 - i) / i;
    return ret;
  }
};

const int kN = 1000000 + 5;
const int kM = kN + kN;
const int MOD = 1e9 + 7;

using Mint = Integral<MOD>;
int n, q;
std::vector<std::string> s;
std::string T;
std::vector<std::array<Mint, 26>> suffix;
char buffer[kN];

Mint inv_pw2[kM];
Mint pw2[kM];

std::vector<int> prepare(const std::string& w) {
  std::vector<int> next(w.size());
  next[0] = -1;
  for (int i = 1, j = -1; i < w.size(); ++i) {
    while (j >= 0 && w[i] != w[j + 1]) j = next[j];
    next[i] = w[i] == w[j + 1] ? ++j : -1;
  }
  return next;
}

int count_occurrence(const std::string& S, const std::string& w, const std::vector<int>& next) {
  int ret = 0;
  for (int i = 0, j = -1; i < S.length(); ++i) {
    while (j >= 0 && S[i] != w[j + 1]) j = next[j];
    if (S[i] == w[j + 1]) {
      ++j;
      if (j + 1 == w.length()) {
        j = next[j];
        ++ret;
      }
    }
  }
  return ret;
}

int solve(int I, const std::string& w) {
  const std::vector<int> next = prepare(w);
  int t = 0;
  while (t < I && s[t].length() <= w.length()) ++t;
  Mint once = count_occurrence(s[t], w, next);
  Mint ret = once * pw2[I - t];
  if (I > 0) {
    for (int c = 0; c < 26; ++c) {
      Mint sp(suffix[t][c] - suffix[I][c]);
      if (sp.val() == 0) continue;
      const Mint table_c = Mint(count_occurrence(s[t] + std::string(1, c + 'a') + s[t], w, next)) - once * Mint(2);
      ret += sp * pw2[I - 1] * table_c;
    }
  }
  return ret.val();
}

int main() {
  pw2[0] = inv_pw2[0] = 1;
  pw2[1] = 2;
  inv_pw2[1] = (MOD + 1) / 2;
  for (int i = 2; i < kM; ++i) {
    pw2[i] = pw2[i - 1] * pw2[1];
    inv_pw2[i] = inv_pw2[i - 1] * inv_pw2[1];
  }
  scanf("%d%d", &n, &q);
  scanf("%s", buffer);
  s.emplace_back(buffer);
  scanf("%s", buffer);
  T = buffer;

  for (int i = 0; i < T.size() && s.back().length() < kN; ++i) {
    s.emplace_back(s.back() + T[i] + s.back());
  }
  suffix.resize(T.length() + 1);
  for (int i = T.length() - 1; i >= 0; --i) {
    suffix[i] = suffix[i + 1];
    suffix[i][T[i] - 'a'] += inv_pw2[i];
  }

  while (q--) {
    int I;
    scanf("%d%s", &I, buffer);
    std::string w = buffer;
    printf("%d\n", solve(I, w));
  }
}