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;
template <typename T>
bool chkmax(T &x, T y) {
  return x < y ? x = y, true : false;
}
template <typename T>
bool chkmin(T &x, T y) {
  return x > y ? x = y, true : false;
}
long long readint() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, d, m;
long long l, r;
long long pw[105], a[30], dp[2][65][60][2], bs[65], pr[105], pl[105];
long long shift(long long x, int t) {
  return (x >> t) | ((x & ((1ll << t) - 1)) << (m - t));
}
long long getans(vector<long long> &b, long long dep, long long now) {
  if (now > r) return 0;
  long long res = 0;
  if (b.size() == 1) {
    for (int i = 0; i < m; i++) {
      if (b[0] & (1ll << i)) {
        if (now <= pr[dep])
          res += dp[0][dep][i][0] + dp[0][dep][i][1];
        else
          res += dp[0][dep][i][0];
        if (now <= pl[dep])
          res -= dp[1][dep][i][0] + dp[1][dep][i][1];
        else
          res -= dp[1][dep][i][0];
      }
    }
    return res;
  }
  for (int i = 0; i < d; i++) {
    vector<long long> nb(0);
    int tmp = i;
    long long mask = (1ll << m) - 1;
    for (int j = 0; j < b.size(); j++) {
      mask &= shift(b[j], a[tmp]);
      tmp++;
      if (tmp == d) {
        tmp = 0;
        nb.push_back(mask);
        mask = (1ll << m) - 1;
      }
    }
    if (tmp != 0) nb.push_back(mask);
    res += getans(nb, dep + 1, now + pw[dep] * i);
  }
  return res;
}
void getdp(long long x, int t) {
  int cnt = 0;
  memset(bs, 0, sizeof(bs));
  for (; x; x /= d) bs[cnt++] = x % d;
  cnt = 60;
  dp[t][cnt][0][1] = 1;
  for (int i = cnt; i >= 1; i--)
    for (int j = 0; j < m; j++)
      for (int c = 0; c <= 1; c++)
        for (int num = 0; num < (c ? bs[i - 1] + 1 : d); num++)
          dp[t][i - 1][(j + a[num]) % m][c & (num == bs[i - 1])] +=
              dp[t][i][j][c];
}
int main() {
  d = readint();
  m = readint();
  pw[0] = 1;
  for (int i = 1; pw[i - 1] <= (1e18 + 10) / d; i++) pw[i] = pw[i - 1] * d;
  for (int i = 1; i <= 100; i++)
    if (!pw[i]) pw[i] = 1e18 + 10;
  for (int i = 0; i < d; i++) a[i] = readint();
  n = readint();
  vector<long long> b(0);
  for (int i = 1; i <= n; i++) b.push_back((1ll << (readint() + 1)) - 1);
  l = readint() - 2;
  r = readint() - n;
  for (int i = 0; i <= 100; i++) pr[i] = r % pw[i];
  for (int i = 0; i <= 100; i++) pl[i] = l % pw[i];
  getdp(r, 0);
  if (l >= 0) getdp(l, 1);
  printf("%lld\n", getans(b, 0, 0));
  return 0;
}