Problems
Farmer John's
The Jaccard similarity of two bitstrings is defined as the number of set bits in their bitwise intersection divided by the number of set bits in their bitwise union. For example, the Jaccard similarity of the bitstrings 11001 and
For each cow, output the sum of her bitstring's Jaccard similarity with each of the
Input
The first line contains
The next
Output
Output the sum modulo
Example
4 2
1
1
2
3
500000006
500000006
500000005
500000006
The cows are associated with the following bitstrings:
For the first cow, the sum is
The second cow's bitstring is the same as the first cow's, so her sum is the same as above.
For the third cow, the sum is