consider the sequence (X1, X2, …, XN) as a number in the form x1x2x3…xN now to find least lexicographic number we should take x1=0 and solve for rest (we are finding the number with 0 as first digit)… so the second lexicographic number would be starting with 1 => x1=1 and so on… so to find the kth lexicographic sequence we xor the whole digits(sequence) with k-1