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:
//#pragma comment(linker, "/stack:200000000")
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define var(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define un(x) x.erase(unique(ALL(x)),x.end())
#define REP(i,x,v)for(int i=x;i<=v;i++)
#define REPD(i,x,v)for(int i=x;i>=v;i--)
#define FOR(i,v)for(int i=0;i<v;i++)
#define TRAV(i,v)for(auto &i:(v))
#define REMIN(x,v) x=min(x,v);
#define REMAX(x,v) x=max(x,v);

mt19937_64 rng(134569);
int rd(int l, int r) {return uniform_int_distribution<int>(l, r)(rng);}

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int MOD=1e9+7;//998244353;


ll mpow(ll a, ll b)
{
    a=a%MOD;
    ll w=1;
    while(b)
    {
        if (b%2) w=(w*a)%MOD;
        a=(a*a)%MOD;
        b/=2;
    }
    return w;
}

ll getp2(int l) {
  if (l>=0) return mpow(2,l);
  return mpow(mpow(2,-l), MOD-2);
}

int kmp(string t, string p) {
   vi kn(SZ(p)+1,-1); // funkcja prefiksowa Knutha
   REP(i,1,SZ(p)) {
      int j = kn[i-1];
      while (j != -1 && p[j] != p[i-1]) j=kn[j];
      kn[i] = j+1;
   }

   int ans=0;
   int ppos=0,tpos=0;
   while (tpos<SZ(t)) {
      while (ppos!=-1 && (ppos == SZ(p) || p[ppos]!=t[tpos])) ppos=kn[ppos];
      ppos++;
      tpos++;
      if (ppos==SZ(p)) ans++;
   }
   return ans;
}

ll p2[(1<<20)+2];
ll p[26][111111];


int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  p2[0]=1;
  REP(i,1,(1<<20)) p2[i]=(p2[i-1]*2)%MOD;

	ios_base::sync_with_stdio(0);cin.tie(0);
	cout << fixed << setprecision(11);
	cerr << fixed << setprecision(6);
  int n,q;cin>>n>>q;
  string s;cin>>s;
  string t;cin>>t;
  FOR(i, SZ(t)) {
    FOR(c,26) {
      p[c][i+1]=(2*p[c][i] +(c+'a'==t[i]))%MOD;
    }
  }

  while(q--) {
    int K;cin>>K;
    string w;cin>>w;
    int k=0;
    string r=s;
    while(SZ(w)>SZ(r)) {
      if (k>=n) break;
      r=r+t.substr(k,1)+r;
      k++;
    }
    if (k>K) {
      cout<<0<<"\n";
      continue;
    }
    if (k==K) {
      cout<<kmp(r,w)<<"\n";
      continue;
    }
    r=r+t.substr(k,1)+r;
    k++;

    int center=SZ(r)/2;
    vi a(26);
    string R=r.substr(center-SZ(w)+1, 2*SZ(w)-1);
    //debug()<<var(t)<<var(r)<<var(w)<<var(R)<<var(k)<<var(K);
    FOR(c,26) {
      R[SZ(w)-1]='a'+c;
      a[c]=kmp(R,w);
    }
    //debug()<<var(a);
    ll sum=(kmp(r,w)*p2[K-k])%MOD;
    ll sum2=0;
    FOR(c,26) {
      sum2=(sum2+a[c]*(p[c][K]-p[c][k]*p2[K-k]))%MOD;
      //debug()<<var(c)<<var(p[c][K]-p[c][k]);
    }
    //debug()<<var(sum)<<var(sum2);
    //sum2=(sum2*getp2(K-k-1))%MOD;

    sum2=(sum2+MOD)%MOD;

    //sum2=(sum2*getp2(K-k-1))%MOD;
    sum=(sum+sum2)%MOD;
    cout<<sum<<"\n";
  }




    return 0;
}