Tap the square horizontally or vertically adjacent to the empty square to move the pieces till you get the original image.