A square is inscribed in a right triangle, as shown below. The legs of the triangle are 1 and 3. Find the area of the square.