Use tries to accelerate merging