#include <stdio.h>
#include <string.h>

#define DATA_MAX 1000000
#define ORDER_MAX 15
#define INPUT_SUCCESS 0
#define EXIT_SUCCESS 0
#define FIRST_ITEM 0
#define LOOP_INIT 0
#define POINTER_INIT 0
#define PREV_ITEM( x ) ( ( x ) - 1 )
#define NEXT_ITEM( x ) ( ( x ) + 1 )

unsigned long aulG_Ddata[ DATA_MAX ];
unsigned long ulG_Ddata_end_p = POINTER_INIT;

int main( void )
{
	unsigned char aubW_Dorder[ ORDER_MAX ];
	unsigned long ulW_Dorder_num;
	unsigned long ulW_Dorder_cnt;
	unsigned long ulW_Cloop_cnt;
	unsigned long ulW_Cdelete_loop_cnt;
	unsigned long ulW_Csqueeze_loop_cnt;
	unsigned long ulW_Dcalc;
	signed long slW_Cout_loop_cnt;

	scanf( "%d", &ulW_Dorder_cnt );
	/* ??????????????? */
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dorder_cnt; ulW_Cloop_cnt++ ){
		scanf( "%s", aubW_Dorder );
		if( strcmp( aubW_Dorder, "insert" ) == INPUT_SUCCESS ){
			scanf( "%d", &ulW_Dorder_num );
			aulG_Ddata[ ulG_Ddata_end_p ] = ulW_Dorder_num;
			ulG_Ddata_end_p++;
		}
		else if( strcmp( aubW_Dorder, "delete" ) == INPUT_SUCCESS ){
			scanf( "%d", &ulW_Dorder_num );
			for( ulW_Cdelete_loop_cnt = LOOP_INIT; ulW_Cdelete_loop_cnt < ulG_Ddata_end_p; ulW_Cdelete_loop_cnt++ ){
				if( aulG_Ddata[ ulW_Cdelete_loop_cnt ] == ulW_Dorder_num ){
					for( ulW_Csqueeze_loop_cnt = ulW_Cdelete_loop_cnt; ulW_Csqueeze_loop_cnt < PREV_ITEM( ulG_Ddata_end_p ); ulW_Csqueeze_loop_cnt++ ){
						aulG_Ddata[ ulW_Csqueeze_loop_cnt ] = aulG_Ddata[ NEXT_ITEM( ulW_Csqueeze_loop_cnt ) ];
					}
					ulG_Ddata_end_p--;
				}
				else{
					/* else?????????????????????????????\ */
				}
			}
		}
		else if( strcmp( aubW_Dorder, "deleteFirst" ) == INPUT_SUCCESS ){
			for( ulW_Csqueeze_loop_cnt = LOOP_INIT; ulW_Csqueeze_loop_cnt < PREV_ITEM( ulG_Ddata_end_p ); ulW_Csqueeze_loop_cnt++ ){
				aulG_Ddata[ ulW_Csqueeze_loop_cnt ] = aulG_Ddata[ NEXT_ITEM( ulW_Csqueeze_loop_cnt ) ];
			}
			ulG_Ddata_end_p--;
		}
		else if( strcmp( aubW_Dorder, "deleteLast" ) == INPUT_SUCCESS ){
			ulG_Ddata_end_p--;
		}
		else{
			/* else?????????????????????????????\ */
		}
	}/* ???????????????????????? */

	/* ??????????????? */
	for( slW_Cout_loop_cnt = PREV_ITEM( ulG_Ddata_end_p ); slW_Cout_loop_cnt >= FIRST_ITEM; slW_Cout_loop_cnt-- ){//????´???????????????????????????¨?????°???
		/* ?????????????´??????´??? */
		if( slW_Cout_loop_cnt == FIRST_ITEM ){
			printf( "%d\n", aulG_Ddata[ slW_Cout_loop_cnt ] );
			break;
		}
		else{
			printf( "%d ", aulG_Ddata[ slW_Cout_loop_cnt ] );
		}
	}/* ???????????????????????? */

	return EXIT_SUCCESS;
}