Ivan loves burgers and spending money. There are burger joints on the street where Ivan
lives. Ivan has friends,and the -th friend suggested to meet at the joint li and walk
to the joint ri(li<ri). While strolling with the i-th friend Ivan can visit all joints
which satisfy li<xi<ri.
For each joint Ivan knows the cost of the most expensive burger in it, it costs
burles. Ivan wants to visit some subset of joints on his way, in each of them he will buy
the most expensive burger and spend the most money. But there is a small issue: his card
broke and instead of charging him for purchases, the amount of money on it changes as
follows.
If Ivan had burles before the purchase and he spent burles at the joint, then after
the purchase he would have burles, where denotes the bitwise XOR operation.
Currently Ivan has burles and he wants to go out for a walk. Help him to determine
the maximal amount of burles he can spend if he goes for a walk with the friend. The
amount of burles he spends is defined as the difference between the initial amount on his
account and the final account.
【Input】
The first line contains one integer n (1<=n<=500000) — the number of burger shops.
The next line contains n integers c1,c2,……,cn(0<=ci<=1e6), where ci — the cost of the
most expensive burger in the burger joint .
The third line contains one integer q (1<=q<=500000) — the number of Ivan's friends.
Each of the next lines contain two integers li and ri (1<=li<=ri<=n) — pairs of numbers
of burger shops between which Ivan will walk.
【Output】
Output q lines,i-th of which containing the maximum amount of money Ivan can spend with
the friend i .