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;
using ll = long long;
const int MAXD = 25;
const int MAXM = 61;
int D, M;
int gen[MAXD];
map<ll, vector<ll>> mem;
vector<ll>& dfs2(ll H) {
  assert(H >= 0);
  if (mem.count(H)) {
    return mem[H];
  }
  auto& res = mem[H] = vector<ll>(size_t(M));
  if (H == 0) {
    res[0]++;
    return res;
  }
  for (int d = 0; d < D && d <= H; d++) {
    vector<ll>& o = dfs2((H - d) / D);
    for (int i = 0; i < M; i++) {
      res[(i + gen[d]) % M] += o[i];
    }
  }
  return res;
}
map<ll, vector<ll>> results;
void dfs(const vector<uint64_t>& B, ll H) {
  if (H < 0) {
    return;
  }
  assert(H >= 0);
  const int N = int(B.size());
  if (N == 1) {
    if (!results.count(H)) {
      results[H] = vector<ll>(M);
    }
    vector<ll>& v = results[H];
    for (int m = 0; m < M; m++) {
      v[m] += bool((B[0]) & (1ll << m));
    }
    return;
  }
  for (int d = 0; d < D && d <= H; d++) {
    ll nxtH = (H - d) / D;
    vector<uint64_t> nxtB(size_t((d + (N - 1)) / D + 1), ((1ll << M) - 1));
    for (int i = 0; i < N; i++) {
      uint64_t msk = B[i];
      int off = gen[(i + d) % D];
      assert(0 <= off && off < M);
      msk = (msk >> off) | (msk << (M - off));
      nxtB[(i + d) / D] &= msk;
    }
    dfs(nxtB, nxtH);
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> D >> M;
  for (int i = 0; i < D; i++) {
    cin >> gen[i];
  }
  assert(gen[0] == 0);
  int N;
  cin >> N;
  vector<uint64_t> B(N);
  for (int i = 0; i < N; i++) {
    int b;
    cin >> b;
    b++;
    B[i] = (1ll << b) - 1;
  }
  ll L, R;
  cin >> L >> R;
  L--;
  R--;
  R++;
  assert(R - L >= N);
  assert(R - N > L - 1);
  dfs(B, L - 1);
  for (auto& it : results) {
    for (ll& v : it.second) {
      v = -v;
    }
  }
  dfs(B, R - N);
  ll res = 0;
  for (auto& it : results) {
    vector<ll>& v = dfs2(it.first);
    for (int i = 0; i < M; i++) {
      res += v[i] * it.second[i];
    }
  }
  cout << res << '\n';
  return 0;
}