trie: transition matrix implementation