O(m log n) still not enough. Have to use binary codes. Fixed some typos.