#include <bits/stdc++.h>
using namespace std;
int main()
{
priority_queue pq;
int q,k;
cin>>q>>k;
for(int i=0;i<q;i++)
{
int type,x,y;
cin>>type;
if(type==1)
{
cin>>x>>y;
pq.push(xx + yy);
if(pq.size() > k)
pq.pop();
}
else if(type==2)
{
cout<<pq.top()<<endl;
}
}
return 0;
}