#include
#include<bits/stdc++.h>
using namespace std;
int main() {
int n,k,type;
long int t;
cin>>n;
cin>>k;
long arr[n];
int a,b,i;
for(i=0;i<k;i++){
cin>>type;
cin>>a;
cin>>b;
t=a*a+b*b;
arr[i]=t;
}
sort(arr,arr+k);
while((n-k)!=0){
cin>>type;
if(type==1){cin>>a;
cin>>b;
t=a*a+b*b;
if(t<arr[k-1])
{
arr[k-1]=t;
sort(arr,arr+k);
}
}
else if(type==2){
cout<<arr[k-1]<<endl;
}
n--;
}
return 0;
}