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 <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <set>
#ifdef XLor
  #define dbg(args...) cout << "\033[32;1m" << #args << " -> ", err(args)
  void err() { std::cout << "\033[39;0m" << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
#else
  #define dbg(...)
#endif
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
using ll = long long;
using PII = pair<int,int>;
const int mod = 1e9 + 7;
const int inf = 1 << 30;
const int maxn = 100000 + 5;

inline int add(int x, int y) {
  x += y;
  return x >= mod ? x -= mod : x;
}
inline int sub(int x, int y) {
  x -= y;
  return x < 0 ? x += mod : x;
}
inline int mul(int x, int y) {
  return 1ll * x * y % mod;
}
inline int qpow(int x, ll n) {
  int r = 1;
  while (n > 0) {
    if (n & 1) r = 1ll * r * x % mod;
    n >>= 1; x = 1ll * x * x % mod;
  }
  return r;
}
inline int inv(int x) {
  return qpow(x, mod - 2);
}

int n, m, q, iv2[maxn], pw2[maxn], suf[maxn][26];
char s[maxn], t[maxn], buf[maxn * 10];

int main() {
  pw2[0] = iv2[0] = 1;
  for (int i = 1; i < maxn; i++) {
    pw2[i] = mul(pw2[i - 1], 2);
    iv2[i] = mul(iv2[i - 1], (mod + 1) / 2);
  }

  scanf("%d%d", &n, &q);
  scanf("%s%s", s, t);
  m = strlen(s);

  for (int i = n; i >= 1; i--) {
    for (int j = 0; j < 26; j++) {
      suf[i][j] = suf[i + 1][j];
    }
    int c = t[i - 1] - 'a';
    suf[i][c] = add(suf[i][c], pw2[n - i]);
  }

  while (q--) {
    int k;
    scanf("%d%s", &k, buf);
    int len = strlen(buf);
    int ans = 0;
    for (int offset = 0; offset <= m; offset++) {
      string str;
      int cur = offset;
      bool ok = true;
      for (int i = 0; i < len; i++) {
        if (cur == m) {
          str += buf[i];
          cur = 0;
        } else {
          if (s[cur] != buf[i]) {
            ok = false;
            break;
          }
          cur++;
        }
      }
      if (!ok) continue;
      if (str.empty()) {
        ans = add(ans, pw2[k]);
        continue;
      }
      // dbg(offset, str);
      function<int(string,int)> solve = [&](string str, int cur) {
        if (cur > k) return 0;
        if (str.size() == 1) {
          int c = str[0] - 'a';
          int ans = sub(suf[cur + 1][c], suf[k + 1][c]);
          // dbg(cur, k, suf[cur + 1][c], suf[k + 1][c]);
          ans = mul(ans, iv2[n - k]);
          return ans;
        }
        int ans = 0;
        {
          bool flag = true;
          for (int i = 0; i < str.size(); i += 2) {
            if (str[i] != t[cur]) {
              flag = false;
              break;
            }
          }
          if (flag) {
            string nxt;
            for (int i = 1; i < str.size(); i += 2) {
              nxt += str[i];
            }
            ans = add(ans, solve(nxt, cur + 1));
          }
        }
        {
          bool flag = true;
          for (int i = 1; i < str.size(); i += 2) {
            if (str[i] != t[cur]) {
              flag = false;
              break;
            }
          }
          if (flag) {
            string nxt;
            for (int i = 0; i < str.size(); i += 2) {
              nxt += str[i];
            }
            ans = add(ans, solve(nxt, cur + 1));
          }
        }
        return ans;
      };
      ans = add(ans, solve(str, 0));
    }
    printf("%d\n", ans);
  }
  return 0;
}