PROBLEM LINKS
DIFFICULTY
MEDIUM
EXPLANATION
At first we have to sort the array A[].
Next let’s do some basic observations. Consider the highest bit. Let its index be H. Then, there are CNT_{0} numbers that have zero Hth bit and CNT_{1} numbers that have unit Hth bit (CNT_{0}+CNT_{1}=N). Then C_{0}=CNT0(CNT_{0}*1)/2+CNT_{1}*(CNT_{1}1)/2 pairwise XORs will have zero Hth bit and *C_{1}=CNT_{0}CNT_{1}  unit Hth bit. If K<=C_{0} then the first K pairwise XORs will have zero in Hth bit. Otherwise all C_{0} pairwise XORs with zero in Hth bit should be added to the resulting array and we should find KC_{0} pairwise XORs that has unit Hth bit.
Now what is going on in the general situation.
There are two possible scenarios when we consider the hth bit (0<=h<=H).

All highest bits from h+1 to H should be zero in the first K pairwise XORs.
Then we handle such an array of segments B that all pairwise XORs that we need can be obtained as pairwise XORs on each segment. In fact these segments are nonintersecting and their union is [0,N). Each segment is composed of these numbers A[i] that have equal bits from h+1 to H. Then we divide each such segment according to the hth bit and check the condition similar to those for the Hth bit (sum CNT(CNT1)/2*) for divided segments. If K<=SUM then for the next bit we will be in this case again. Otherwise we have to add all pairwise XORs for all segments to the answer, decrease K by SUM and create an array of pairs of segments C={([L1_{i},R1_{i}), [L2_{i},R2_{i})):1<=i<=Nh} with meaning that our remaining pairwise XORs included in XORs of the form A xor B where A belongs to [L1_{i},R1_{i}) and B belongs to [L2_{i},R2_{i}) for every i. 
We have an array C of pairs of segments and required pairwise XORs included in pairwise XORs of numbers in segments of C as described above.
Now the consideration is a bit different. Let’s consider a pair of segments [L1,R1), [L2,R2). Then on [L1,M1) we have zero hth bit for all A[i], L1 <= i < M1 and on [M1,R1)  unit hth bit. M2 has the same meaning. Then zero hth bit has pairwise XORs of segments [L1,M1) and [L2,M2) and also [M1,R1) and [M2,R2). So there are (M2L2) * (M1L1)+(R1M1) * (R2M2) numbers in total. If the sum S of all these numbers for all pairs of segments is more or equal to K then our K XORs are among them and we replace each pair {[L1,R1), [L2,R2)} by two pairs {[L1,M1), [L2,M2)} and {[M1,R1), [M2,R2)} and pass to (h1)th bit. Otherwise we have to add all these pairwise XORs to the resulting array, decrease K by S and replace each pair {[L1,R1), [L2,R2)} by two pairs {[L1,M1), [M2,R2)} and {[M1,R1), [L2,M2)} (where hth is equal to one). But if in some pair we have an empty segment this pair should be ignored. Hence, B and C have no more than N segments. After we pass 0th bit we still may have some segments or pairs of segments left. In fact each segment now contains equal numbers. So pairwise XORs would also be equal and we can analyze this case easily.
Finally we sort the result array and print it.
P.S: Such a solution worked for 0.60.8 sec. on a maximal test case, so the Time Limit wasn’t really strict.
SETTER’S SOLUTION
Can be found here.
TESTER’S SOLUTION
Can be found here.