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(3)
using namespace std;
using ull = uint64_t;
using ll = int64_t;
using ld = long double;
const int D = 22;
const int M = 62;
const int B = 62;
const int N = 30228;
int n, d, m;
ll MASK;
int gen[D];
int b[N];
ll rot(ll x, int y) { return ((x >> y) + (x << (m - y))) & MASK; }
struct LBorder {
  ll g[N];
  ll len;
  LBorder() : g{}, len(0) { fill(g, g + n + 1, MASK); }
  ll at(ll x) const { return (x < n) ? g[x] : MASK; }
  LBorder rot(int y) const {
    LBorder ans;
    ans.len = len;
    for (int i = 0; i < n; ++i) {
      ans.g[i] = ::rot(g[i], y);
    }
    return ans;
  }
  friend LBorder operator+(const LBorder& lhs, const LBorder& rhs) {
    LBorder ans;
    ans.len = lhs.len + rhs.len;
    for (int i = 0; i <= n; ++i) {
      ans.g[i] = lhs.at(i) & rhs.at(i + lhs.len);
    }
    return ans;
  }
};
struct RBorder {
  ll g[N];
  ll len;
  RBorder() : g{}, len(0) { fill(g, g + n + 1, MASK); }
  ll at(ll x) const { return (x > 0) ? g[x] : MASK; }
  RBorder rot(int y) const {
    RBorder ans;
    ans.len = len;
    for (int i = 0; i < n; ++i) {
      ans.g[i] = ::rot(g[i], y);
    }
    return ans;
  }
  friend RBorder operator+(const RBorder& lhs, const RBorder& rhs) {
    RBorder ans;
    ans.len = lhs.len + rhs.len;
    for (int i = 0; i <= n; ++i) {
      ans.g[i] = rhs.at(i) & lhs.at(i - rhs.len);
    }
    return ans;
  }
};
struct Value {
  LBorder l;
  RBorder r;
  ll a[M];
  Value() : a{} {}
  void solo() {
    for (int i = 0; i < n; ++i) {
      l.g[i] = r.g[i + 1] = (1ll << (b[i] + 1)) - 1;
    }
    l.len = r.len = 1;
    if (n == 1) {
      for (int i = 0; i <= b[0]; ++i) {
        ++a[i];
      }
    }
  }
  ll len() const { return l.len; }
  Value rot(int y) const {
    Value res;
    res.l = l.rot(y);
    res.r = r.rot(y);
    for (int i = 0; i < m; ++i) {
      res.a[i] = a[(i + y) % m];
    }
    return res;
  }
  friend Value operator+(const Value& lhs, const Value& rhs) {
    Value ans;
    ans.l = lhs.l + rhs.l;
    ans.r = lhs.r + rhs.r;
    for (int i = 0; i < m; ++i) {
      ans.a[i] = lhs.a[i] + rhs.a[i];
    }
    for (int i = 1; i < n; ++i) {
      if (i <= lhs.len() && i + rhs.len() >= n) {
        ll cur = lhs.r.at(i) & rhs.l.at(i);
        for (int j = 0; j < m; ++j) {
          ans.a[j] += (cur >> j) & 1;
        }
      }
    }
    return ans;
  }
};
Value f[B];
ll pw[B];
int k;
void precalc(ll r) {
  f[0].solo();
  pw[0] = 1;
  while (r / pw[k] >= d) {
    ++k;
    f[k] = Value();
    pw[k] = pw[k - 1] * d;
    for (int i = 0; i < d; ++i) {
      f[k] = f[k] + f[k - 1].rot(gen[i]);
    }
  }
}
ll eval(ll x) {
  int y = 0;
  Value cur;
  for (int i = k; i >= 0; --i) {
    int cn = x / pw[i];
    assert(cn < d);
    for (int j = 0; j < cn; ++j) {
      cur = cur + f[i].rot((y + gen[j]) % m);
    }
    y = (y + gen[cn]) % m;
    x %= pw[i];
  }
  return cur.a[0];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.setf(ios::fixed);
  cout.precision(20);
  cin >> d >> m;
  MASK = (1ll << m) - 1;
  for (int i = 0; i < d; ++i) {
    cin >> gen[i];
  }
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  ll l, r;
  cin >> l >> r;
  precalc(r);
  ll ar = eval(r);
  ll al = eval(l + n - 2);
  cout << ar - al << "\n";
}
