We call a sequence A=(A1,A2,…,An) of length n beautiful when all the following conditions are true:
-
A1≤A2≤⋯≤An
-
For each Ai (1≤i≤n), 0≤Ai<230.
-
For each 1≤i<n, Ai⊕Ai+1=Bi , where B is a given sequence, and ⊕ represents bitwise XOR.
You need to find the k-th smallest lexicographically legal beautiful sequence A.