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 cat = long long;
int D, M;
vector<int> gen;
cat cnt[80][20][20][8];
void solve_cnt() {
  vector<vector<cat> > cnt_sum(81, vector<cat>(M, 0));
  cnt_sum[0][0] = 1;
  for (int i = 0; i < 80; i++)
    for (int j = 0; j < M; j++)
      for (int k = 0; k < D; k++)
        cnt_sum[i + 1][(j + gen[k]) % M] += cnt_sum[i][j];
  for (int i = 0; i < 80; i++)
    for (int j = 0; j < M; j++)
      for (int k = 0; k < D; k++)
        cnt[i][k][((j + gen[k]) % M) / 3][1 << ((j + gen[k]) % M % 3)] =
            cnt_sum[i][j];
  for (int i = 0; i < 80; i++)
    for (int k = 0; k < D; k++)
      for (int j = 0; j < 20; j++) {
        cnt[i][k][j][3] = cnt[i][k][j][1] + cnt[i][k][j][2];
        cnt[i][k][j][5] = cnt[i][k][j][1] + cnt[i][k][j][4];
        cnt[i][k][j][6] = cnt[i][k][j][2] + cnt[i][k][j][4];
        cnt[i][k][j][7] = cnt[i][k][j][1] + cnt[i][k][j][2] + cnt[i][k][j][4];
      }
  for (int i = 0; i < 80; i++)
    for (int j = 0; j < 20 * 8; j++)
      for (int k = 1; k < D; k++)
        cnt[i][k][j / 8][j % 8] += cnt[i][k - 1][j / 8][j % 8];
}
vector<cat> masks_pos[80][20];
vector<cat> masks_neg[80][20];
cat ans = 0;
constexpr int L_masks = 100;
cat __attribute__((optimize("Ofast,unroll-loops")))
fast_inner_loop(const cat* __restrict masks_ptr,
                const cat* __restrict cnt_ptr) {
  cat ret = 0;
  for (int l = 0; l < L_masks; l++, masks_ptr++) {
    cat m = *masks_ptr;
    for (const cat* __restrict p = cnt_ptr; m;) {
      ret += p[m & 7];
      p += 8;
      m >>= 3;
      ret += p[m & 7];
      p += 8;
      m >>= 3;
      ret += p[m & 7];
      p += 8;
      m >>= 3;
      ret += p[m & 7];
      p += 8;
      m >>= 3;
    }
  }
  return ret;
}
void solve_leaf(cat A_mask, cat Xl, cat Xr) {
  static vector<char> Vl;
  Vl.clear();
  static vector<char> Vr;
  Vr.clear();
  while (Xl) {
    Vl.push_back(Xl % D);
    Xl /= D;
  }
  while (Xr) {
    Vr.push_back(Xr % D);
    Xr /= D;
  }
  while (!Vl.empty() && !Vr.empty() && Vl.size() == Vr.size() &&
         Vl.back() == Vr.back()) {
    int s = gen[Vl.back()];
    A_mask = (A_mask >> s) | ((A_mask & ((1LL << s) - 1)) << (M - s));
    Vl.pop_back();
    Vr.pop_back();
  }
  for (int i = (int)Vr.size() - 1, s = 0; i >= 0; i--) {
    cat mask = (A_mask >> s) | ((A_mask & ((1LL << s) - 1)) << (M - s));
    if (mask && Vr[i]) {
      masks_pos[i][Vr[i] - 1].push_back(mask);
      if ((int)masks_pos[i][Vr[i] - 1].size() == L_masks) {
        cat* cnt_ptr = &(cnt[i][Vr[i] - 1][0][0]);
        const cat* masks_ptr = masks_pos[i][Vr[i] - 1].data();
        ans += fast_inner_loop(masks_ptr, cnt_ptr);
        masks_pos[i][Vr[i] - 1].clear();
      }
    }
    s += gen[Vr[i]];
    if (s >= M) s -= M;
  }
  for (int i = (int)Vl.size() - 1, s = 0; i >= 0; i--) {
    cat mask = (A_mask >> s) | ((A_mask & ((1LL << s) - 1)) << (M - s));
    if (mask && Vl[i]) {
      masks_neg[i][Vl[i] - 1].push_back(mask);
      if ((int)masks_neg[i][Vl[i] - 1].size() == L_masks) {
        cat* cnt_ptr = &(cnt[i][Vl[i] - 1][0][0]);
        const cat* masks_ptr = masks_neg[i][Vl[i] - 1].data();
        ans -= fast_inner_loop(masks_ptr, cnt_ptr);
        masks_neg[i][Vl[i] - 1].clear();
      }
    }
    s += gen[Vl[i]];
    if (s >= M) s -= M;
  }
}
void solve_recursive(vector<cat>& A_mask, cat Xl, cat Xr) {
  int N = A_mask.size();
  for (int i = 0; i < D; i++) {
    if (Xr - 1 - i < 0) break;
    vector<cat> A_mask_new;
    A_mask_new.reserve(A_mask.size() / D + 2);
    for (int j = 0, k = i, l = 0; j < N; j++, k++) {
      if (A_mask[j] == 0) return;
      if (k == D) k = 0, l++;
      int g = gen[k];
      cat mask_new =
          (A_mask[j] >> g) | ((A_mask[j] & ((1LL << g) - 1)) << (M - g));
      if ((int)A_mask_new.size() == l) A_mask_new.push_back((1LL << M) - 1);
      A_mask_new[l] &= mask_new;
    }
    if (A_mask_new.size() == 1)
      solve_leaf(A_mask_new[0], (Xl - 1 - i >= 0) ? (Xl - 1 - i) / D + 1 : 0,
                 (Xr - 1 - i) / D + 1);
    else
      solve_recursive(A_mask_new, (Xl - 1 - i >= 0) ? (Xl - 1 - i) / D + 1 : 0,
                      (Xr - 1 - i) / D + 1);
  }
}
void solve(vector<int>& B, cat Xl, cat Xr) {
  int N = B.size();
  vector<cat> A_mask(N);
  for (int i = 0; i < N; i++) A_mask[i] = (1LL << (B[i] + 1)) - 1;
  if (N == 1)
    solve_leaf(A_mask[0], Xl, Xr);
  else
    solve_recursive(A_mask, Xl, Xr);
}
int main() {
  cin.sync_with_stdio(0);
  cin >> D >> M;
  gen.resize(D);
  for (int i = 0; i < D; i++) cin >> gen[i];
  solve_cnt();
  int N;
  cin >> N;
  vector<int> B(N);
  for (int i = 0; i < N; i++) cin >> B[i];
  cat L, R;
  cin >> L >> R;
  L--, R--;
  solve(B, L, R - N + 2);
  for (int i = 0; i < 80; i++)
    for (int j = 0; j < D; j++) {
      masks_pos[i][j].resize(L_masks, 0);
      ans += fast_inner_loop(masks_pos[i][j].data(), &(cnt[i][j][0][0]));
    }
  for (int i = 0; i < 80; i++)
    for (int j = 0; j < D; j++) {
      masks_neg[i][j].resize(L_masks, 0);
      ans -= fast_inner_loop(masks_neg[i][j].data(), &(cnt[i][j][0][0]));
    }
  cout << ans << "\n";
}