taking nfa as input