Max XOR With Element From Array

You are given an array nums of non-negative integers and a list of queries. Each query contains a number x and a limit m. For each query, find the maximum XOR of x with any element from nums that is ≤ m. If no such element exists, return -1. Queries are answered offline by sorting and using a binary trie.

Examples
Input: [[0,1,2,3,4],[[3,1],[1,3],[5,6]]]
Output: [3,3,7]
Hints

Max XOR With Element From Array

You are given an array nums of non-negative integers and a list of queries. Each query contains a number x and a limit m. For each query, find the maximum XOR of x with any element from nums that is ≤ m. If no such element exists, return -1. Queries are answered offline by sorting and using a binary trie.