#include <bits/stdc++.h>
using namespace std;
class Hostel{
public:
int x ;
int y;
Hostel(int x , int y ){
this -> x = x;
this -> y = y;
}
int dist(){
return x*x + y*y;
}
void print(){
cout << x*x + y*y<<endl;
}
};
class HostelCompare{
public :
bool operator()(Hostel a , Hostel b){
return a.dist() > b.dist();
}
};
int main(){
priority_queue<Hostel , vector,HostelCompare> pq;
int n , k;
cin >> n >> k;
for(int i =0; i < n ; i ++){
int q;
cin >> q;
if(q==1){
int xx , yy;
cin >> xx >> yy;
Hostel h (xx,yy);
pq.push(h);
}
else{
i=1;
while(!pq.empty()&&i<k){
pq.pop();
}
Hostel p = pq.top();
p.print();
// cout << p.x;
}
}
return 0;}