//* #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") //*/ #include // #include using namespace std; // using namespace atcoder; #define DEBUG(x) cerr<<#x<<": "< #define vl vector #define vii vector< vector > #define vll vector< vector > #define vs vector #define pii pair #define pis pair #define psi pair #define pll pair template pair operator+(const pair &s, const pair &t) { return pair(s.first + t.first, s.second + t.second); } template pair operator-(const pair &s, const pair &t) { return pair(s.first - t.first, s.second - t.second); } template ostream& operator<<(ostream& os, pair p) { os << "(" << p.first << ", " << p.second << ")"; return os; } #define X first #define Y second #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<=(int)(n);i++) #define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--) #define rrep1(i,n) for(int i=(int)(n);i>0;i--) #define REP(i,a,b) for(int i=a;i bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; } #define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end()); const ll inf = 1000000001; const ll INF = (ll)1e18 + 1; const long double pi = 3.1415926535897932384626433832795028841971L; #define Sp(p) cout<> n >> k >> x >> y; assert(n % 2 == 0); assert(n <= 40); assert(k <= 200000); ll times = 1; rep (i, n) times *= k; assert(times <= 2.1 * 1e15); vl a(k); rep (i, k) cin >> a[i]; sort(all(a)); UNIQUE(a); if (n >= 10) { rep (i, a.size()) { dp[1][i][a[i]] = 1; } rep1 (i, n - 1) { rep (j, a.size()) rep (k, 1024) { if (dp[i][j][k] == 0) continue; rep (l, a.size()) { if (j == l) continue; (dp[i + 1][l][k ^ a[l]] += dp[i][j][k]) %= MOD; } } } ll ans = 0; rep (i, 1024) { if (i < x or i > y) continue; rep (j, a.size()) { ans += dp[n][j][i]; } } ans %= MOD; cout << ans << endl; } else { vii dp(n + 1, vi(1024)); dp[0][0] = 1; rep (i, n) { rep (j, 1024) { for (int u: a) { (dp[i + 1][j ^ u] += dp[i][j]) %= MOD; } } } ll ans = 0; rep (i, 1 << (n - 1)) { int cnt = 0; int num = 0; int now = 1; ll bonus = 1; rep (j, n - 1) { if (i & (1 << j)) { cnt++; now = 1 - now; } else { if (now == 0) (bonus *= a.size()) %= MOD; else num += now; now = 1; } } if (now == 0) (bonus *= a.size()) %= MOD; else num += now; rep (i, 1024) { if (in(i, x, y + 1)) { if (cnt % 2 == 0) { ans += dp[num][i] * bonus % MOD; } else { ans -= dp[num][i] * bonus % MOD; } ans %= MOD; } } } cout << (ans + MOD) % MOD << endl; } }