// editor4
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct Node
{
    int id,priority;
    struct Node*next;
}Node;
Node*head=NULL;

void insert(int id,int priority)
{
    Node*n=malloc(sizeof(Node));
    n->id=id;n->prior=priority; n->next=NULL;
    if(!head||priority>head->priority){
        n->next=head;
        head=n;
        retuen 0;
        
    }
    Node*t=head;
    while (t->next && t->next-> priority>=priority)
    t=t-> next;
    n->next=y->next'
    t->next=n;
}
void delete()
{
    if(!head) printf("Queue is empty\n");
    else{
    Node*t=head;
    head=head->next;
    free(temp);
}
}
int main(){
    int n,id,p;
    char op[10];
    scanf("%d",&n);
    for (int i=0;i<n;i++){
        scanf("%d",&op);
        if(!strcmp(op,"INSERT"))
        {
            scanf("%d %d",&id,&p);
            if(p<1||p>100||id<1id>100000){
                printf("Invalid input");
                return 0;
            }
            insert(id,p);
        }
    }
    else if(!strcmp(op,"DELETE"))
    delete();
    else{
        printf("Invalid input\n");
        return 0;
    }
}