math && SuffixArray && some graph theory