implement wavelet tree to support rank(c, p) and uniq(begin, end)