#include<iostream> #include<cstdlib> #include<cstdio> #define ll long long usingnamespacestd; inlineintread() { int f = 1, x = 0; char ch;
do{ ch = getchar(); if (ch == '-') f = -1; }while(ch < '0' || ch > '9'); do{ x = x * 10 + ch - '0'; ch = getchar(); }while(ch >= '0' && ch <= '9'); return f * x; } constint N = 50;
int n, k, s, t, S, sum; int pow2[18]; int a[N + 1], buc[1 << 18]; ll f[N + 1][N + 1], C[N + 1]; ll ans;
inlinevoidinit() { f[0][0] = 1; for (int i = 1; i <= N; i++) { f[i][0] = 1; for (int j = 1; j <= i; j++) f[i][j] = f[i - 1][j] + f[i - 1][j - 1]; } for (int i = 1; i <= N; i++) for (int j = 1; j <= i && j <= k; j++) C[i] += f[i][j]; for (int i = N; i >= 1; i--) C[i] -= C[i - 1]; return; } intmain() { n = read(); k = read(); s = read(); t = read(); init(); pow2[0] = 1; for (int i = 1; i < 18; i++) pow2[i] = 2 * pow2[i - 1]; for (int i = 0; i < 18; i++) { if (t & pow2[i] && !(s & pow2[i])) { S |= pow2[i]; sum++; } } for (int i = 1; i <= n; i++) { a[i] = read(); for (int j = 0; j < 18; j++) { if (s & pow2[j] && !(a[i] & pow2[j])) { i--; n--; continue; } if (!(t & pow2[j]) && a[i] & pow2[j]) { i--; n--; continue; } } } if (!n) { printf("0\n"); return0; }
while (true) { ll per = 0; for (int i = 1; i <= n; i++) per += C[++buc[a[i] & S]]; if (sum & 1) ans -= per; else ans += per; for (int i = 1; i <= n; i++) buc[a[i] & S] = 0; if (!S) break; S = (S - 1) & (s ^ t); sum = 0; for (int i = 0; i < 18; i++) if (S & pow2[i]) sum++; }