The problem involves a Eulerian circuit (Eulerian circuit), that is a trail in a graph which visits every edge exactly once and ends on the same vertex it started.