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>
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long Inf = 1e18;
const int mod = 0;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
template <typename T>
bool chkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
};
template <typename T>
bool chkmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
};
int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
void inc(int &a, int b) { a = (a + b >= mod ? a + b - mod : a + b); }
void dec(int &a, int b) { a = (a - b < 0 ? a - b + mod : a - b); }
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + "," + to_string(p.second) + ")";
}
template <typename T>
string to_string(T v) {
  int fst = 1;
  string ret = "{";
  for (auto x : v) {
    if (!fst) ret += ",";
    fst = 0, ret += to_string(x);
  }
  ret += "}";
  return ret;
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  dbg_out(T...);
}
const int N = 3e4 + 10;
int d, m, n, B[N], gen[N];
long long l, r;
bitset<N> all;
struct data {
  long long len = 0, ans = 0;
  bitset<N> pre, suf;
  data operator+(const data &A) const {
    if (len == 0) return A;
    data B;
    B.len = len + A.len;
    B.ans = ans + A.ans;
    B.pre = pre;
    B.suf = A.suf;
    if (len <= n - 2) B.pre &= (A.pre >> len) | (all << (n - 1 - len));
    if (A.len <= n - 2) B.suf &= (suf << A.len) | (all >> (n - 1 - A.len));
    if (len + A.len >= n) {
      bitset<N> can = suf & A.pre;
      if (len <= n - 2) can &= all >> (n - 1 - len);
      if (A.len <= n - 2) can &= all << (n - 1 - A.len);
      B.ans += can.count();
    }
    return B;
  }
};
data f[70][70];
int dep = 0;
long long solve(long long n) {
  int tag = 0;
  data ret;
  for (int i = dep; ~i; i--) {
    for (int j = 1; j <= d; j++) {
      if (n >= f[i][(tag + gen[j]) % m].len)
        ret = ret + f[i][(tag + gen[j]) % m], n -= f[i][(tag + gen[j]) % m].len;
      else {
        tag = (tag + gen[j]) % m;
        break;
      }
    }
  }
  return ret.ans;
}
int main() {
  d = gi(), m = gi();
  for (int i = 1; i <= d; i++) gen[i] = gi();
  n = gi();
  for (int i = 1; i <= n; i++) B[i] = gi();
  for (int i = 1; i <= n - 1; i++) all[i] = 1;
  cin >> l >> r;
  for (int i = 0; i < m; i++) {
    f[0][i].len = 1;
    if (n == 1)
      f[0][i].ans = (i <= B[1]);
    else
      for (int j = 1; j <= n - 1; j++)
        f[0][i].pre[j] = (i <= B[j + 1]), f[0][i].suf[j] = (i <= B[j]);
  }
  while (f[dep][0].len <= r / d) {
    ++dep;
    for (int i = 0; i < m; i++) {
      for (int j = 1; j <= d; j++)
        f[dep][i] = f[dep][i] + f[dep - 1][(i + gen[j]) % m];
    }
  }
  printf("%lld\n", solve(r) - solve(l + n - 2));
  return 0;
}
