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>
void maxtt(T &t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T &t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "URDL";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
int d, gen[33], B[30135];
bitset<30135> all;
struct nd {
  long long len, num;
  bitset<30135> pre, suf;
  nd() {
    len = num = 0;
    pre.reset();
    suf.reset();
  }
  friend nd operator+(const nd &a, const nd &b) {
    if (a.len == 0) return b;
    nd res;
    res.len = a.len + b.len;
    res.num = a.num + b.num;
    res.pre = a.pre;
    res.suf = b.suf;
    if (a.len < n - 1) {
      res.pre &= (b.pre >> a.len) | all << (n - 1 - a.len);
    }
    if (b.len < n - 1) {
      res.suf &= (a.suf << b.len) | all >> (n - 1 - b.len);
    }
    if (res.len >= n) {
      bitset<30135> tmp = a.suf & b.pre;
      if (a.len < n - 1) tmp &= all >> (n - 1 - a.len);
      if (b.len < n - 1) tmp &= all << (n - 1 - b.len);
      res.num += tmp.count();
    }
    return res;
  }
} f[70][65];
long long pw[77], l, r;
void init() {
  pw[0] = 1;
  for (int(i) = 1; (i) <= (int)(70); (i)++) pw[i] = pw[i - 1] * d;
  int c = 0;
  while (pw[c + 1] < r) c++;
  for (int(i) = 1; (i) <= (int)(n - 1); (i)++) all[i] = 1;
  for (int(j) = 0; (j) < (int)(m + 1); (j)++) {
    f[0][j].len = 1;
    if (n == 1)
      f[0][j].num = j <= B[1];
    else {
      for (int i = 1; i <= n; i++) {
        f[0][j].pre[i - 1] = j <= B[i];
        f[0][j].suf[i] = j <= B[i];
      }
    }
  }
  for (int(i) = 1; (i) <= (int)(c); (i)++) {
    for (int(j) = 0; (j) < (int)(m + 1); (j)++) {
      for (int(k) = 0; (k) < (int)(d); (k)++) {
        f[i][j] = f[i][j] + f[i - 1][(j + gen[k]) % m];
      }
    }
  }
}
long long cal(long long x) {
  int c = 0;
  while (pw[c + 1] < x) c++;
  nd res;
  int add = 0;
  for (int i = c; i >= 0; i--) {
    for (int(j) = 0; (j) < (int)(d); (j)++) {
      if (x >= pw[i]) {
        x -= pw[i];
        res = res + f[i][(add + gen[j]) % m];
      } else {
        add += gen[j];
        break;
      }
    }
  }
  return res.num;
}
void fmain(int tid) {
  scanf("%d%d", &d, &m);
  for (int(i) = 0; (i) < (int)(d); (i)++) scanf("%d", gen + i);
  scanf("%d", &n);
  for (int(i) = 1; (i) <= (int)(n); (i)++) scanf("%d", B + i);
  scanf("%lld%lld", &l, &r);
  init();
  printf("%lld\n", cal(r) - cal(l + n - 1 - 1));
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}