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;
int get() {
  char ch;
  while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-')
    ;
  if (ch == '-') {
    int s = 0;
    while (ch = getchar(), ch >= '0' && ch <= '9') s = s * 10 + ch - '0';
    return -s;
  }
  int s = ch - '0';
  while (ch = getchar(), ch >= '0' && ch <= '9') s = s * 10 + ch - '0';
  return s;
}
const int N = 3e4 + 5;
const int M = 65;
int d, m;
int g[25];
int b[N], n;
bool can[N][16][M];
long long mi[N];
long long L, R;
long long f[M][M][M];
int digi[M], a[M];
int sum[N * 20];
int sec[N], k, start[N], val[N];
bool yes1[M], yes2[M];
long long solve(long long r) {
  if (r < 0) return 0;
  for (long long i = 0, x = r; i <= 60; x /= d, i++) digi[i] = x % d;
  int L = 0;
  for (; mi[L] <= n; L++)
    ;
  for (int i = 0; i <= 60; i++)
    for (int p = 0; p <= m - 1; p++)
      for (int u = 0; u <= m - 1; u++) f[i][p][u] = 0;
  int pp = 0, uu = g[1];
  for (int i = 60; i >= 1; i--) {
    for (int x = 0; x <= digi[i] - 1; x++) {
      int p = (pp + g[x]) % m;
      int u;
      if (x == d - 1)
        u = (uu + m - g[x]) % m;
      else
        u = (g[x + 1] + m - g[x]) % m;
      f[i][p][u]++;
    }
    pp = (pp + g[digi[i]]) % m;
    if (digi[i] == d - 1)
      uu = (uu + m - g[d - 1]) % m;
    else
      uu = (g[digi[i] + 1] + m - g[digi[i]]) % m;
    for (int p = 0; p <= m - 1; p++)
      for (int u = 0; u <= m - 1; u++)
        if (f[i][p][u]) {
          for (int x = 0; x <= d - 1; x++) {
            int p_ = (p + g[x]) % m;
            int u_;
            if (x == d - 1)
              u_ = (u + m - g[x]) % m;
            else
              u_ = (g[x + 1] + m - g[x]) % m;
            f[i - 1][p_][u_] += f[i][p][u];
          }
        }
  }
  long long ret = 0;
  int p1 = 0, u1 = g[1];
  for (int i = 60; i >= L; i--) {
    p1 = (p1 + g[digi[i]]) % m;
    if (digi[i] == d - 1)
      u1 = (u1 + m - g[d - 1]) % m;
    else
      u1 = (g[digi[i] + 1] + m - g[digi[i]]) % m;
  }
  for (int i = 0; i <= mi[L] - 1; i++) {
    sum[i] = 0;
    for (int x = i; x; x /= d) sum[i] += g[x % d];
    sum[i] %= m;
  }
  int cnt = 0;
  for (int st = 0; st <= mi[L] - 1; st++) {
    k = 0;
    int mid = -1;
    for (int x = 1, now = st; x <= n;) {
      int w1 = 0, w2 = 0;
      for (; x + mi[w1 + 1] - 1 <= n; w1++)
        ;
      for (; w2 < L && now % mi[w2 + 1] == 0; w2++)
        ;
      int w = min(w1, w2);
      sec[++k] = w;
      start[k] = x;
      val[k] = now;
      x += mi[w];
      now += mi[w];
      if (now >= mi[L]) mid = k + 1, now -= mi[L];
    }
    if (mid == -1) mid = k + 1;
    for (int i = 0; i <= m - 1; i++) yes1[i] = yes2[i] = 1;
    for (int i = 1; i <= mid - 1; i++)
      for (int p = 0; p <= m - 1; p++)
        yes1[p] &= can[start[i]][sec[i]][(p + sum[val[i]]) % m];
    for (int i = mid; i <= k; i++)
      for (int p = 0; p <= m - 1; p++)
        yes2[p] &= can[start[i]][sec[i]][(p + sum[val[i]]) % m];
    for (int p = 0; p <= m - 1; p++)
      if (yes1[p])
        for (int u = 0; u <= m - 1; u++)
          if (yes2[(p + u) % m]) {
            ret = ret + f[L][p][u];
            cnt++;
          }
    if (yes1[p1] && yes2[(p1 + u1) % m] && r % mi[L] >= st) ret++;
  }
  return ret;
}
int main() {
  d = get();
  m = get();
  for (int i = 0; i <= d - 1; i++) g[i] = get();
  n = get();
  for (int i = 1; i <= n; i++) b[i] = get();
  mi[0] = 1;
  for (int i = 1; i <= 16; i++) mi[i] = mi[i - 1] * d;
  for (int i = n; i >= 1; i--) {
    for (int p = 0; p <= b[i]; p++) can[i][0][p] = 1;
    for (int j = 1; i + mi[j] - 1 <= n; j++)
      for (int p = 0; p <= m - 1; p++) {
        can[i][j][p] = 1;
        for (int x = 0; x <= d - 1; x++)
          can[i][j][p] &= can[i + x * mi[j - 1]][j - 1][(p + g[x]) % m];
      }
  }
  cin >> L >> R;
  R = R - n + 1;
  L--, R--;
  long long vr = solve(R);
  long long vl = solve(L - 1);
  cout << vr - vl << endl;
  return 0;
}
