Start by building a suffix trie.