Two congruent squares and are positioned such that they share a common area defined by . The ratio of the area of to the area of polygon is .
If the side length of both squares is , then the perimeter of polygon is , where and are coprime positive integers. Find .