Company: Infosys SP
Difficulty: medium
Bitwise XOR of Sweet Indices A sweet shop contains n different varieties of sweets. The sweetness of the i th sweet is given by a i . Robin went to the shop to eat sweets. He orders a total of q sweets. Each order consists of two numbers, k and l , given in an array Q . Now, Robin wants to find the largest index r ( l ≤ r ≤ n ) such that the bitwise AND of the sweetness values from sweet l to sweet r (inclusive) is at least k . In other words: (a l & a l+1 & ... & a r ) ≥ k If such a sweet doesn\'t exist, take r as n+1 . He then buys the r th sweet if r is less than n+1 . Find the bitwise XOR of the indices r of the sweets he buys. Note: Here \'&\' is a bitwise AND operator. Input Format The first line contains an integer n , denoting the number of different types of sweets. Each line i of the n subsequent lines contains an integer describing a[i] . The next line contains an integer q , denoting the number of rows in Q . Each line i of the q subsequent lines contains 2 space-separa