poj2945. string. hash + binary-search. trie would be an good option.