Approach hintTry it first, then revealHide
To make the message lexicographically smallest, fix positions from left to right and give each one the remaining key that minimises its XOR. A binary trie with counters finds that key greedily and supports deletion.