import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int numCases = sc.nextInt();
int k = sc.nextInt();
PriorityQueue<Long> pq = new PriorityQueue<>(Collections.reverseOrder());
long KthValue = Integer.MAX_VALUE;
for (int i = 1; i <= numCases; i++)
{
int type = sc.nextInt();
if (type == 1)
{
int x = sc.nextInt();
int y = sc.nextInt();
long dist = (x * x) + (y * y);
if (pq.size() >= k)
{
if (pq.peek() > dist)
{
pq.poll();
pq.add(dist);
}
} else
{
pq.add(dist);
}
} else
{
System.out.println(pq.peek());
}
}
sc.close();
}
}
