Because of the great success of Villages: Landlines, its development team, NIO Tech, decides to develop its sequel. They call it Villages: Landcircles. In the sequel, the development team decides to use a new power system.
They change the power system from one dimension to two dimensions. In the new power system, initially there are several power stations and buildings. The goal of the game is to make every power stations and buildings connected together in the power system, forming a connected graph. Players can build some power towers and wires in the game, which are the tools to connect power stations and buildings.
Power stations or buildings can connect to power towers without wires, while power towers must connect to each other by wires. What's more, power stations and buildings can't connect to each other directly, they must connect through power towers.
Assuming that the coordinates of a building are (xi,yi)(x_i,y_i)(xi,yi) and its receiving radius is rir_iri, all the power towers whose distance from the building is no greater than rir_iri are directly connected to it without wires. That is to say, for the power tower located at (x,y)(x,y)(x,y), it is directly connected to the building at (xi,yi)(x_i,y_i)(xi,yi) without wires if and only if (x−xi)2+(y−yi)2≤ri\sqrt{(x-x_i)^2+(y-y_i)^2}\leq r_i(x−xi)2+(y−yi)2≤ri. Similarly, assuming that the power supply radius of a power station is rsr_srs, all the power towers whose distance from the power station is no more than rsr_srs are directly connected to it without wires. Supposing that the coordinates of two power towers are (xA,yA)(x_A,y_A)(xA,yA) and (xB,yB)(x_B,y_B)(xB,yB), players can connect them with the wire, and the length of wire required is (xA−xB)2+(yA−yB)2\sqrt{(x_A-x_B)^2+(y_A-y_B)^2}(xA−xB)2+(yA−yB)2. A power tower can be connected to any number (possibly zero) of power towers, buildings and power stations.
In order to make the game more friendly to the rookies, Mocha, a member of
NIO Tech, decides to develop the power distribution recommendation function. In the case of using any number of power towers, pla
yers can choose exactly one power station and several buildings to get an optimal power supply scheme, which uses the shortest total length of wires to complete the power system. However, Mocha is not sure whether her scheme is correct, so she needs your help to calculate the total length of wires used in the optimal scheme to determine the correctness of her scheme.