This is a simple trie exercise.