Source: https://web.cs.hacettepe.edu.tr/~ilyas/Courses/BIL405/lec02_FiniteAutomata.pdf