Approach hintTry it first, then revealHide
Answer the queries offline in increasing order of m, inserting array values into a binary trie only once they do not exceed m. Each query is then a plain maximum-XOR lookup, or -1 while the trie is empty.