How to Solve Jigsaw Puzzles Efficiently