A Combinatorial Rearrangement Problem with Implications to the Embedding of Graphs