Experimental demonstration of quantum finite automaton