#include <stdio.h>

int list[1000000];

int main(int argc, const char * argv[]) {
    int i, j, n, x, tail, head;
    char o[20];
    scanf("%d", &n);
    head = n - 1;
    tail = n;
    
    for(i = 0;i < n;i++){
        scanf("%s %d", o, &x);
        if(o[0] == 'i' && o[6] == 'F'){
            list[head] = x;
            head--;
        }else if(o[0] == 'i' && o[6] == 'L'){
            list[tail] = x;
            tail++;
        }else if(o[0] == 'd' && o[6] == 'F'){
            head++;
        }else if(o[0] == 'd' && o[6] == 'L'){
            tail--;
        }else if(o[0] == 'd' && o[6] == 'A'){
            head = n - 1;
            tail = n;
            list[head] = -1;
            list[tail] = -1;
        }else{
            for(j = head;j <= tail;j++){
                if(list[j] == x){
                    list[j] = -1;
                }
            }
            
        }
    }
    for(i = head + 1;i <= tail - 1;i++){
        if(list[i] == -1){
            continue;
        }else{
            printf("%d", list[i]);
            if(i < tail - 1){
                printf(" ");
            }
        }
    }
    printf("\n");
    return 0;
}