#include<bits/stdc++.h>
using namespace std;
#define ll long long int
/*class compare
{
public:
bool operator()(int a,int b){
return a<b;
}
};*/
int main()
{
int q,k;
cin>>q>>k;
priority_queue pq;
int count=0;
while(q–)
{
int type;
cin>>type;
if(type==1)
{
count++;
int x,y;
cin>>x>>y;
ll d=xx+yy;
if(count<=k)
{
pq.push(d);
}
else
{
ll z=pq.top();
if(d<=z)
{
pq.pop();
pq.push(d);
}
}
}
if(type==2)
{
cout<<pq.top()<<endl;
}
}
/* while(!pq.empty())
{
cout<<pq.top()<<" ";
pq.pop();
}*/
return 0;
}