Automata and planar graphs