import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
PriorityQueue<Long> maxHeap = new PriorityQueue<>(new Comparator<Long>() {
@Override
public int compare(Long o1, Long o2) {
return o2.compareTo(o1);
}
});
int i=sc.nextInt();
int k=sc.nextInt();
//System.out.println(i);
for(;i>0;i--)
{
int query;
long y,x;
query=sc.nextInt();
if(query==1)
{
x=sc.nextLong();
y=sc.nextLong();
maxHeap.add(x*x+y*y);
}
else if(query ==2) {
int diff=maxHeap.size()-k;
while(diff>0)
{
maxHeap.poll();
diff--;
}
System.out.println(maxHeap.poll());
}
}
}
}