selecting borders for swapping rectangles