Minimum XOR for queries
Using Trie Data Structure, you can solve this problem in $O(m + n)$ if we know that values are computer integers (e.g. all 32-bit or 64-bit values). 

Let say we know that all integers in $A$ are 32-bit values. Use the following steps: 


Create an empty trie. Every node of trie may contains at most two children
for 0 and 1 bits.
Insert all values in $A$ into the tree in $O(32 \times m) = O(m)$
For each value in $B$, traverse the tree from the leftmost bit. If a bit doesn't match with child of a middle node, continue the traverse using the existing child until you reach a leaf. Traversing finishes in $O(32 \times n) = O(n)$


Which in total, the complexity is $O(m + n)$.