Problem: A Thue-Morse-Radecki-Mateusz sequence (Thorse-Radewoosh sequence in short) is an infinite sequence constructed from a finite sequence gen of length d and an integer m, obtained in the following sequence of steps:

  * In the beginning, we define the one-element sequence M_0=(0).
  * In the k-th step, k ≥ 1, we define the sequence M_k to be the concatenation of the d copies of M_{k-1}. However, each of them is altered slightly — in the i-th of them (1 ≤ i ≤ d), each element x is changed to (x+gen_i) \pmod{m}. 



For instance, if we pick gen = (0, \color{blue}{1}, \color{green}{2}) and m = 4: 

  * M_0 = (0), 
  * M_1 = (0, \color{blue}{1}, \color{green}{2}), 
  * M_2 = (0, 1, 2, \color{blue}{1, 2, 3}, \color{green}{2, 3, 0}), 
  * M_3 = (0, 1, 2, 1, 2, 3, 2, 3, 0, \color{blue}{1, 2, 3, 2, 3, 0, 3, 0, 1}, \color{green}{2, 3, 0, 3, 0, 1, 0, 1, 2}), and so on. 



As you can see, as long as the first element of gen is 0, each consecutive step produces a sequence whose prefix is the sequence generated in the previous step. Therefore, we can define the infinite Thorse-Radewoosh sequence M_∞ as the sequence obtained by applying the step above indefinitely. For the parameters above, M_∞ = (0, 1, 2, 1, 2, 3, 2, 3, 0, 1, 2, 3, 2, 3, 0, 3, 0, 1, ...).

Mateusz picked a sequence gen and an integer m, and used them to obtain a Thorse-Radewoosh sequence M_∞. He then picked two integers l, r, and wrote down a subsequence of this sequence A := ((M_∞)_l, (M_∞)_{l+1}, ..., (M_∞)_r).

Note that we use the 1-based indexing both for M_∞ and A.

Mateusz has his favorite sequence B with length n, and would like to see how large it is compared to A. Let's say that B majorizes sequence X of length n (let's denote it as B ≥ X) if and only if for all i ∈ \{1, 2, ..., n\}, we have B_i ≥ X_i.

He now asks himself how many integers x in the range [1, |A| - n + 1] there are such that B ≥ (A_x, A_{x+1}, A_{x+2}, ..., A_{x+n-1}). As both sequences were huge, answering the question using only his pen and paper turned out to be too time-consuming. Can you help him automate his research?

Input

The first line contains two integers d and m (2 ≤ d ≤ 20, 2 ≤ m ≤ 60) — the length of the sequence gen and an integer used to perform the modular operations. The second line contains d integers gen_i (0 ≤ gen_i < m). It's guaranteed that the first element of the sequence gen is equal to zero.

The third line contains one integer n (1 ≤ n ≤ 30000) — the length of the sequence B. The fourth line contains n integers B_i (0 ≤ B_i < m). The fifth line contains two integers l and r (1 ≤ l ≤ r ≤ 10^{18}, r-l+1 ≥ n).

Output

Print a single integer — the answer to the problem.

Examples

Input


2 2
0 1
4
0 1 1 0
2 21


Output


6


Input


3 4
0 1 2
2
0 2
6 11


Output


1

Note

Thorse-Radewoosh sequence in the first example is the standard Thue-Morse sequence, so the sequence A is as follows: 11010011001011010010. Here are the places where the sequence B majorizes A:

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXBASE = 20;
const int MAXB = 30000;
const int MAXLG = 100;
const int MAXMOD = 60;
int base, MOD;
int gen[MAXBASE];
int nb;
int b[MAXB];
long long ql, qr;
int bfcalc(int na) {
  vector<int> a(na, 0);
  for (int i = (0); i < (na); ++i) {
    int x = i;
    while (x != 0) a[i] += gen[x % base], x /= base;
    a[i] %= MOD;
  }
  printf("a:");
  for (int i = (0); i < (((int)(a).size())); ++i) printf(" %d", a[i]);
  puts("");
  int ret = 0;
  for (int i = (0); i <= (((int)(a).size()) - nb); ++i) {
    bool ok = true;
    for (int j = (0); j < (nb); ++j)
      if (b[j] < a[i + j]) {
        ok = false;
        break;
      }
    if (ok) ++ret;
  }
  return ret;
}
int d[MAXLG], nd;
long long dp[MAXLG + 1][MAXMOD];
long long dpsum[MAXLG + 1][MAXMOD][MAXMOD];
void dbuild(long long len) {
  nd = 0;
  for (long long x = len; x != 0; x /= base) d[nd++] = x % base;
  reverse(d, d + nd);
}
long long calc(long long len, int want) {
  int have = 0;
  for (int i = (0); i < (nd); ++i) have += gen[d[i]];
  have %= MOD;
  long long ret = 0;
  for (int i = nd - 1; i >= 0; --i) {
    have -= gen[d[i]];
    if (have < 0) have += MOD;
    int need = want - have;
    if (need < 0) need += MOD;
    ret += dpsum[nd - i - 1][need][d[i]];
  }
  return ret;
}
map<long long, int> mem2;
vector<vector<long long>> memvals;
long long calcmask(long long len, long long mask) {
  if (!mem2.count(len)) {
    dbuild(len);
    vector<long long> vals(MOD);
    for (int i = (0); i < (MOD); ++i) vals[i] = calc(len, i);
    memvals.push_back(vals);
    mem2[len] = ((int)(memvals).size()) - 1;
  }
  int idx = mem2[len];
  long long ret = 0;
  for (int i = (0); i < (MOD); ++i)
    if ((mask & (1LL << i)) != 0) ret += memvals[idx][i];
  return ret;
}
map<pair<long long, vector<long long>>, long long> mem;
long long rec(long long len, vector<long long> mask, int dep = 0) {
  if (((int)(mask).size()) > len) return 0;
  assert(((int)(mask).size()) > 0);
  if (((int)(mask).size()) == 1) return calcmask(len, mask[0]);
  long long ret = 0;
  for (int offset = (0); offset < (base); ++offset)
    if (offset + ((int)(mask).size()) <= len) {
      vector<long long> nmask;
      bool ok = true;
      for (int i = (0); i < (((int)(mask).size())); ++i) {
        int idx = (offset + i) / base, delta = gen[(offset + i) % base];
        long long cmask = (mask[i] >> delta) |
                          ((mask[i] & ((1LL << delta) - 1)) << (MOD - delta));
        if (idx >= ((int)(nmask).size()))
          nmask.push_back(cmask);
        else {
          nmask[idx] &= cmask;
          if (nmask[idx] == 0) {
            ok = false;
            break;
          }
        }
      }
      if (!ok) continue;
      long long nlen =
          (len - ((int)(mask).size()) - offset) / base + ((int)(nmask).size());
      if (nlen >= len) {
        for (int rep = (0); rep < (dep); ++rep) printf("  ");
        printf(
            "len does not decrease (len=%lld nlen=%lld SZ(mask)=%d "
            "SZ(nmask)=%d "
            "offset\n",
            len, nlen, ((int)(mask).size()), ((int)(nmask).size()), offset);
        continue;
      }
      ret += rec(nlen, nmask, dep + 1);
    }
  return ret;
}
long long calc(long long na) {
  vector<long long> smask(nb);
  for (int i = (0); i < (nb); ++i) smask[i] = (2LL << b[i]) - 1;
  long long have = rec(na, smask);
  return have;
}
long long solve() {
  mem.clear();
  mem2.clear();
  memvals.clear();
  for (int j = (0); j < (MOD); ++j) dp[0][j] = j == 0 ? 1 : 0;
  for (int i = (1); i <= (MAXLG); ++i)
    for (int j = (0); j < (MOD); ++j) {
      dp[i][j] = 0;
      for (int k = (0); k < (base); ++k)
        dp[i][j] += dp[i - 1][(j + MOD - gen[k]) % MOD];
    }
  for (int i = (0); i <= (MAXLG); ++i)
    for (int j = (0); j < (MOD); ++j) {
      dpsum[i][j][0] = 0;
      for (int k = (0); k < (base); ++k)
        dpsum[i][j][k + 1] = dpsum[i][j][k] + dp[i][(j + MOD - gen[k]) % MOD];
    }
  long long ret = calc(qr + 1) - calc(ql + nb - 1);
  return ret;
}
void run() {
  scanf("%d%d", &base, &MOD);
  for (int i = (0); i < (base); ++i) scanf("%d", &gen[i]);
  scanf("%d", &nb);
  for (int i = (0); i < (nb); ++i) scanf("%d", &b[i]);
  scanf("%lld%lld", &ql, &qr), --ql, --qr;
  printf("%lld\n", solve());
}
void stress() {
  for (int rep = (0); rep < (1000); ++rep) {
    base = 20;
    MOD = 60;
    gen[0] = 0;
    for (int i = (1); i < (base); ++i) gen[i] = rand() % MOD;
    nb = MAXB;
    for (int i = (0); i < (nb); ++i) b[i] = MOD - 1;
    for (int i = (0); i < (10); ++i) {
      int idx = rand() % nb;
      --b[idx];
      if (b[idx] < 0) b[idx] += MOD;
    }
    ql = rand() % 1000 * 1000000000000000LL + rand() % 1000 * 1000000000000LL +
         rand() % 1000 * 1000000000LL + rand() % 1000 * 1000000 +
         rand() % 1000 * 1000 + rand() % 1000 + 1;
    qr = rand() % 1000 * 1000000000000000LL + rand() % 1000 * 1000000000000LL +
         rand() % 1000 * 1000000000LL + rand() % 1000 * 1000000 +
         rand() % 1000 * 1000 + rand() % 1000 + 1;
    if (ql > qr) swap(ql, qr);
    printf("base=%d MOD=%d ql=%lld qr=%lld\n", base, MOD, ql, qr);
    long long have = solve();
    printf("=%lld\n", have);
  }
}
int main() {
  run();
  return 0;
}