POJ#1231 search, trick to reduce complexity. Rank:8625