atcoder#TOKIOMARINE2020E. O(rand)

O(rand)

Score : 800800 points

Problem Statement

Given are NN pairwise distinct non-negative integers A1,A2,,ANA_1,A_2,\ldots,A_N. Find the number of ways to choose a set of between 11 and KK numbers (inclusive) from the given numbers so that the following two conditions are satisfied:

  • The bitwise AND of the chosen numbers is SS.
  • The bitwise OR of the chosen numbers is TT.

Constraints

  • 1N501 \leq N \leq 50
  • 1KN1 \leq K \leq N
  • 0Ai<2180 \leq A_i < 2^{18}
  • 0S<2180 \leq S < 2^{18}
  • 0T<2180 \leq T < 2^{18}
  • AiAjA_i \neq A_j (1i<jN1 \leq i < j \leq N)

Input

Input is given from Standard Input in the following format:

NN KK SS TT

A1A_1 A2A_2 ...... ANA_N

Output

Print the answer.

3 3 0 3
1 2 3
2

The conditions are satisfied when we choose {1,2}\{1,2\} or {1,2,3}\{1,2,3\}.

5 3 1 7
3 4 9 1 5
2
5 4 0 15
3 4 9 1 5
3