Wavelet Tree implementation