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;
const double pi = acos(-1.0);
const double eps = 1e-11;
template <class T>
inline void ckmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void ckmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
int MOD;
int m;
vector<int> gen;
int n;
vector<int> a;
long long cnt[256][64];
unordered_map<long long, vector<long long>> htable;
void prepare() {
  htable.clear();
  memset(cnt, 0, sizeof(cnt));
  cnt[0][0] = 1;
  for (int i = 0; i < (250); ++i)
    for (int j = 0; j < (MOD); ++j)
      if (cnt[i][j])
        for (int k = 0; k < (m); ++k)
          cnt[i + 1][(j + gen[k]) % MOD] += cnt[i][j];
}
inline long long circular_shift_right(long long s, int d) {
  return (s >> d) | ((s & ((((long long)(1)) << (d)) - 1)) << (MOD - d));
}
long long calc(long long w, long long mask) {
  if (w < 0) return 0;
  vector<long long> &wcnt = htable[w];
  if (((int)wcnt.size()) == 0) {
    wcnt = vector<long long>(MOD);
    vector<int> digits;
    for (long long t = w + 1; t > 0; t /= m) digits.push_back(t % m);
    int s = 0;
    for (int i = 0; i < (((int)digits.size())); ++i) s += gen[digits[i]];
    for (int i = 0; i < (((int)digits.size())); ++i) {
      s -= gen[digits[i]];
      for (int d = 0; d < (digits[i]); ++d) {
        int s0 = s + gen[d];
        for (int w = 0; w < (MOD); ++w) wcnt[(s0 + w) % MOD] += cnt[i][w];
      }
    }
  }
  long long ret = 0;
  for (int i = 0; i < (MOD); ++i)
    if ((((mask) & (((long long)(1)) << (i))) != 0)) ret += wcnt[i];
  assert(ret <= w + 1);
  return ret;
}
long long solve(vector<long long> a, long long w) {
  if (w < 0) return 0;
  if (((int)a.size()) == 1) return calc(w, a[0]);
  vector<long long> b;
  long long ret = 0;
  for (int md = 0; md < (m); ++md)
    if (md <= w) {
      b.clear();
      bool ok = true;
      for (int i = 0; i < (((int)a.size())); ++i) {
        int at = (i + md) / m;
        int pos = (i + md) % m;
        for (; at >= ((int)b.size());
             b.push_back((((long long)(1)) << (MOD)) - 1))
          ;
        b[at] &= circular_shift_right(a[i], gen[pos]);
        if (b[at] == 0) {
          ok = false;
          break;
        }
      }
      if (ok) ret += solve(b, (w - md) / m);
    }
  assert(ret <= w + 1);
  return ret;
}
long long solve(long long w) {
  if (w < 0) return 0;
  vector<long long> mask(n);
  for (int i = 0; i < (n); ++i)
    for (int k = 0; k < (a[i] + 1); ++k) mask[i] |= (((long long)(1)) << (k));
  return solve(mask, w);
}
int main() {
  std::ios::sync_with_stdio(false);
  while (cin >> m >> MOD) {
    gen = vector<int>(m);
    for (int i = 0; i < (m); ++i) cin >> gen[i];
    cin >> n;
    a = vector<int>(n);
    for (int i = 0; i < (n); ++i) cin >> a[i];
    long long l, r;
    cin >> l >> r;
    --l;
    --r;
    prepare();
    long long ret = solve(r - n + 1) - solve(l - 1);
    cout << ret << endl;
    break;
  }
  return 0;
}