  InterviewBit Academy is now Scaler Academy! # WiFi Routers

Given A users and B Wifi routers in an office. A matrix C of size A x 2 denoting the coordinates of
users in 2D plane, where C[i] represents the x-coordinate and C[i]
represents the y-coordinate of the ith
user.
A matrix D of size B x 2 denoting the coordinates of
Wifi Routers in 2D plane, where D[i] represents the x-coordinate and C[i]
represents the y-coordinate of the ith Wifi Router.

You have to make the office fully Wifi-enabled. Now each Wifi Router can only transmit data to a user or another WiFi Router only if the distance between the Router and the receiving user/router is not more than R.
Each Wifi Router has the same range R.
A Wifi Router can get data from the ground network or another Wifi Router. The aim here is that all the users get the data.

You have to find the minimal value of R that will
ensure that all users get the data even if only one WiFi router is connected with the ground network.

Distance between two points P1 (x1,y1) and P2 (x2,y2) = sqrt ( (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) ).

The original answer can be a real value you have to return the square of the minimal value of R.

Note: No two routers/users occupy the same place.

Input Format

``````The first argument given is an integer A.
The second argument given is an integer B.
The third argument given is matrix C.
The fourth argument given is matrix D.
``````

Output Format

``````Return the square of minimal R that ensures ensure that all users get the data even if only one WiFi router is
connected with the ground network.
``````

Constraints

``````1 <= A, B <= 100
0 <= C[i], C[i], D[i], D[i] <= 100
``````

For Example

``````Input 1:
A = 1
B = 2
C = [   [1, 1]   ]
D = [   [0, 0]
[0, 2]   ]
Output 1:
2
Explanation 1:
Connect any of the two routers with the ground newtork.
Minimal R = sqrt(2)
so answer = sqrt(2) ^2 = 2.

Input 2:
A : 7
B : 3
C : [   [5, 0]
[9, 8]
[9, 4]
[6, 3]
[1, 7]
[7, 4]
[4, 0]  ]
D : [   [1, 0]
[8, 8]
[4, 7]  ]
Output 2:
58
``````
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details. 