#include <iostream>
#include <string>
#include <deque>
#include <algorithm>
using namespace std;

int main()
{
  int n;
  cin >> n;

  deque<int> d;
  string cmd;
  while (cin >> cmd)
  {
    if (cmd == "deleteFirst")
    {
      d.pop_front();
    }
    else if (cmd == "deleteLast")
    {
      d.pop_back();
    }
    else
    {
      int x;
      cin >> x;

      if (cmd == "insert")
      {
        d.push_front(x);
      }
      else if (cmd == "delete")
      {
        auto res = find(d.begin(), d.end(), x);
        if (res != d.end())
        {
          d.erase(res);
        }
      }
    }
  }

  for (int i = 0; i < d.size(); i++)
    cout << (i ? " " : "") << d[i];
  cout << "\n";
}
