#include using namespace std; template struct mod_int{ T v; mod_int(): v(0) {} mod_int(T t) { v=t%MOD; if(v<0) v+=MOD; } mod_int inv() const { T a=v, b=MOD, u=1, v=0; while (b>0) { T t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); } return u; } mod_int pow(long long p) const { mod_int ret = 1, base(v); while (p > 0) { if (p & 1) ret *= base; base *= base; p >>= 1; } return ret; } mod_int& operator+=(const mod_int &a) { v+=a.v; if(v>=MOD)v-=MOD; return *this; } mod_int& operator-=(const mod_int &a) { v+=MOD-a.v; if(v>=MOD)v-=MOD; return *this; } mod_int& operator*=(const mod_int &a) { v=v*a.v%MOD; return *this; } mod_int& operator/=(const mod_int &a) { return (*this)*=a.inv(); } mod_int operator+(const mod_int &a) const { return mod_int(v)+=a; } mod_int operator-(const mod_int &a) const { return mod_int(v)-=a; } mod_int operator*(const mod_int &a) const { return mod_int(v)*=a; } mod_int operator/(const mod_int &a) const { return mod_int(v)/=a; } friend mod_int operator+(T x, const mod_int& m) { return mod_int(x)+m; } friend mod_int operator-(T x, const mod_int& m) { return mod_int(x)-m; } friend mod_int operator*(T x, const mod_int& m) { return mod_int(x)*m; } friend mod_int operator/(T x, const mod_int& m) { return mod_int(x)/m; } mod_int operator-() const{ return v?mod_int(MOD-v):mod_int(v); } bool operator==(const mod_int &a) const { return v==a.v; } bool operator!=(const mod_int &a) const { return v!=a.v; } bool operator<(const mod_int &a) const { return v >(istream& is, mod_int& m){ T t; is>>t; m=mod_int(t); return is; } friend ostream& operator<<(ostream& os,const mod_int& m){ return os<; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, k, x, y; cin >> n >> k >> x >> y; vector a(k); for (int i = 0; i < k; i++) cin >> a[i]; vector > cur(1024, vector(1025)); cur[0][1024] = 1; for (int t = 0; t < n; t++) { vector > nxt(1024, vector(1025)); for (int i = 0; i < 1024; i++) { mint sum = 0; for (int j = 0; j <= 1024; j++) sum += cur[i][j]; for (int j = 0; j < a.size(); j++) { nxt[i^a[j]][a[j]] += sum - cur[i][a[j]]; } } cur = nxt; } mint ret = 0; for (int i = x; i <= y; i++) { for (int j = 0; j < 1024; j++) ret += cur[i][j]; } cout << ret << endl; return 0; }