luogu#P4869. albus就是要第一个出场

albus就是要第一个出场

Problem Description

Given a positive integer sequence AA of length nn (indices start from 11), let S={x1xn}S = \{ x | 1 \le x \le n \}. The power set 2S2^S is defined as the set consisting of all subsets of SS. Define a mapping f:2SZf : 2^S \to Z, where f()=0f(\emptyset) = 0, and for a non-empty set TT, f(T)=XOR{At},(tT)f(T) = \mathrm{XOR}\{A_t\}, (t \in T).

Now Albus computes the value ff for every set in 2S2^S, sorts these values in non-decreasing order into a sequence, and denotes it as sequence BB (indices start from 11).

Given a number, what is the index of its first occurrence in sequence BB?

Input Format

The first line contains an integer nn, the length of sequence AA. The next line contains nn integers representing AA, separated by spaces. The last number is QQ, the given number.

Output Format

Output one line with one integer: the value of the index of the first occurrence of QQ in sequence BB modulo 1008610086.

3
1 2 3
1
3

Hint

[Sample Explanation]

N=3,A=[1,2,3]N = 3,A = [1,2,3]
S={1,2,3}S = \{1,2,3\}
$2^S = \{\emptyset,\{1\},\{2\},\{3\},\{1,2\},\{1,3\},\{2,3\},\{1,2,3\}\}$
f()=0f(\emptyset) = 0
f(1)=1f({1}) = 1
f(2)=2f({2}) = 2
f(3)=3f({3}) = 3
f(1,2)=1xor2=3f({1, 2}) = 1 \operatorname{xor} 2 = 3
f(1,3)=1xor3=2f({1, 3}) = 1 \operatorname{xor} 3 = 2
f(2,3)=2xor3=1f({2, 3}) = 2 \operatorname{xor} 3 = 1
f(1,2,3)=0f({1, 2, 3}) = 0
Therefore,
B=[0,0,1,1,2,2,3,3]B = [0,0,1,1,2,2,3,3]

[Constraints]

1N10,00001 \leq N \leq 10,0000
All other inputs do not exceed 10910^9.

Translated by ChatGPT 5