change HashSet to LinkedHashSet, and that's AC. But I think HashSet is better.