aaabbb q1, a -> q2, #, R q2, a -> q2, a, R q2, b -> q2, b, R q2, # -> q3, #, L q3, b -> q4, #, L q4, a -> q4, a, L q4, b -> q4, b, L q4, # -> q1, #, R q1, # -> qf, #, R