#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct node{
    int id;
    struct node *next;
    struct node *prev;
}Node;
Node *front=NULL,*rear=NULL;
void prio(int num){
    Node *newnode=malloc(sizeof(Node));
    newnode->id=num;
    newnode->next=NULL;
    newnode->prev=NULL;
    if(front==NULL){
        front=newnode;
        rear=nwenode;
    }
    else{
        newnode->prev=rear->next;
        rear->next=newnode;
        rear=newnode;
    }
}
void gen(int num){
    Node *newnode=malloc(sizeof(Node));
    newnode->id=num;
    newnode->next=NULL;
    newnode->prev=NULL;
    if(front==NULL){
        front=newnode;
        rear=newnode;
    }
    else{
        newnode->prev=rear->next;
        rear->next=newnode;
        rear=newnode;
    }
}

void display(){
    if(front==NULL){
        printf("Queue is Empty");
        return;
    }
    while(front!=NULL){
        printf("%d ",front->id);
        front=front->next;
    }
}

void board(){
    if(front==NULL){
        printf("Queue is Empty");
        return;
    }
    printf("%d ",front->next->id);
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
    char str[20];
    scanf("%d",str);
        int num;
        scanf("%d",&num);
    }
    if(strcmp(str,"priority_board")==0){
        prio(num);
    }
    else if(strcmp(str,"general_board")==0){
        gen(int num);
    }
    else if(strcmp(str,"display")==0){
        display();
    }
    else if(strcmp(str,"board_train")==0){
        board();
    }
    return 0;
}