#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
using namespace std;
struct custom
{
string name;
int vip;
bool operator < (const custom &c) const
{
return vip<c.vip;
}
}ct;
priority_queue<custom> q;
int main()
{
string op,name;
int n,i,j,vip;
scanf("%d",&n);
for(i=0;i<n;i++)
{
cin>>op;
if(op=="PUT")
{
cin>>ct.name>>ct.vip;
q.push(ct);
}
else if(op=="GET")
{
if(q.size()!=0)
{
ct = q.top();
cout<<ct.name<<endl;
q.pop();
}
else
cout<<"Sleep!"<<endl;
}
}
return 0;
}
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
using namespace std;
struct custom
{
string name;
int vip;
bool operator < (const custom &c) const
{
return vip<c.vip;
}
}ct;
priority_queue<custom> q;
int main()
{
string op,name;
int n,i,j,vip;
scanf("%d",&n);
for(i=0;i<n;i++)
{
cin>>op;
if(op=="PUT")
{
cin>>ct.name>>ct.vip;
q.push(ct);
}
else if(op=="GET")
{
if(q.size()!=0)
{
ct = q.top();
cout<<ct.name<<endl;
q.pop();
}
else
cout<<"Sleep!"<<endl;
}
}
return 0;
}