racers

There are N bikers present in a city (shaped as a grid) having M bikes. All the bikers want to participate in the HackerRace competition, but unfortunately only K bikers can be accommodated in the race. Jack is organizing the HackerRace and wants to start the race as soon as possible. He can instruct any biker to move towards any bike in the city. In order to minimize the time to start the race, Jack instructs the bikers in such a way that the first K bikes are acquired in the minimum time.

Every biker moves with a unit speed and one bike can be acquired by only one biker. A biker can proceed in any direction. Consider distance between bikes and bikers as Euclidean distance.

Jack would like to know the square of required time to start the race as soon as possible. 

Input Format
The first line contains three integers, N, M, and K, separated by a single space. 
The following N lines will contain N pairs of integers denoting the co-ordinates of N bikers. Each pair of integers is separated by a single space. The next M lines will similarly denote the co-ordinates of the M bikes.

Output Format

A single line containing the square of required time.

Constraints

1≤N≤250

1≤M≤250

1≤K≤min(N,M)

0≤xi, yi ≤107

SAMPLE INPUT
3 3 2
0 1
0 2
0 3
100 1
200 2 
300 3

SAMPLE OUTPUT
40000

Explanation

There's need for two bikers for the race. The first biker (0,1) will be able to reach the first bike (100,1) in 100 time units. The second biker (0,2) will be able to reach the second bike (200,2) in 200 time units. This is the most optimal solution and will take 200 time units. So output will be 2002 = 40000.

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
from sys import stdin
import math
from operator import indexOf
    
def dist(a,b):
	return (((a[0]-b[0])*(a[0]-b[0])+((a[1]-b[1])*(a[1]-b[1]))))
					  
def main():
	N,M,K = list(map(int, stdin.readline().split()))
	bikers = []
	bikes = []
	for i in range(N):
		bikers.append(list(map(int, stdin.readline().split())))
	for i in range(M):
		bikes.append(list(map(int, stdin.readline().split())))        
		
	distanceArr =[]
	for i in range(len(bikers)):
		distances ={}
		for j in range(len(bikes)):
			distances[j] = dist(bikers[i], bikes[j])
		distanceArr.append(distances)
		
	for i in range(K):
		lenArr = len(distanceArr)
		minArr = [0]*lenArr
		for j in range(lenArr):
			minArr[j] = min(distanceArr[j].values())
		
		result = min(minArr)
		ind = indexOf(minArr,result)
		#print "index : "+str(ind)
		
		k = [x for x in distanceArr[ind] if distanceArr[ind][x] == result]
		
		#print k[0]
		
		del distanceArr[ind]
		
		for h in range(lenArr-1):
			del distanceArr[h][k[0]]
		
		
		
	
	print(result)
	
main()