complete the Query Method for ACAutomaton