Andy: I think it is the optimized version using trie. But TLE!