Source: https://web.engr.oregonstate.edu/~huanlian/teaching/nlp/2017spring/slides/lec-2-FSAFSTs.pdf