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>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const int MN = 30010;
int D, M, N;
int G[66], B[MN];
long long L, R;
unordered_map<long long, vector<int> > cnt;
long long shift(long long bit, int k) {
  return (bit >> k) + (1LL << (M - k)) * (bit & ((1LL << k) - 1));
}
void solve(long long r, vector<long long> &X, int t) {
  if (r + 1 < X.size()) return;
  if (X.size() == 1) {
    if (cnt.find(r) == cnt.end()) {
      cnt[r] = vector<int>(M, 0);
    }
    for (int i = 0; i < M; i++)
      if (X[0] & (1LL << i)) cnt[r][i] += t;
    return;
  }
  if (r == 0) return;
  int n = X.size();
  for (int i = 0; i < D; i++) {
    vector<long long> x((i + n - 1) / D + 1, (1LL << M) - 1);
    for (int j = 0; j < n; j++) {
      x[(i + j) / D] &= shift(X[j], G[(i + j) % D]);
    }
    if (r >= (i + n - 1) % D) solve((r - (i + n - 1) % D) / D, x, t);
  }
}
vector<int> A;
long long dp[2][66][2];
void init(long long r) {
  A.clear();
  while (r) {
    A.push_back(r % D);
    r /= D;
  }
  memset(dp[1], 0, sizeof(dp[1]));
  dp[1][0][0] = dp[1][0][1] = 1;
  for (int i = 0; i < A.size(); i++) {
    for (int j = 0; j < M; j++) {
      for (int k = 0; k < 2; k++) {
        int c = i & 1;
        int p = c ^ 1;
        dp[c][j][k] = 0;
        for (int a = 0; a <= (k ? A[i] : D - 1); a++) {
          dp[c][j][k] += dp[p][(j + M - G[a]) % M][k & (a == A[i])];
        }
      }
    }
  }
}
int main() {
  scanf("%d %d", &D, &M);
  for (int i = 0; i < D; i++) {
    scanf("%d", &G[i]);
  }
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &B[i]);
  }
  scanf("%lld %lld", &L, &R);
  L--;
  R--;
  vector<long long> X(N);
  for (int i = 0; i < N; i++) {
    X[i] = (1LL << (B[i] + 1)) - 1;
  }
  solve(L + N - 2, X, -1);
  solve(R, X, 1);
  long long ans = 0;
  for (auto it = cnt.begin(); it != cnt.end(); it++) {
    long long r = it->first;
    vector<int> X = it->second;
    init(r);
    for (int i = 0; i < M; i++) ans += dp[(int)(A.size() - 1) & 1][i][1] * X[i];
  }
  printf("%lld", ans);
}
