/**
 * Author: Sergey Kopeliovich (Burunduk30@gmail.com)
 * Date: 2014.03.16
 * OK, Time: 0.281
 */

#include <cstdio>
#include <cassert>
#include <algorithm>

using namespace std;

#define forn(i, n) for (int i = 0; i < (int)(n); i++)

const int N = (int)1e5;
const int K = 500;
const int M = 1000;

struct seg
{
  int n, *a;
};

int sn, n, m, mem[2][2 * N], *a = mem[0], *b = mem[1];
seg s[N];

void shift( int p )
{
  for (int j = sn++; j > p; j--)
    s[j] = s[j - 1];
}

void erase( int p )
{
  for (sn--; p < sn; p++)
    s[p] = s[p + 1];
}

int split( int i )
{
  int p = 0;
  while (i && i >= s[p].n)
    i -= s[p++].n;
  if (!i)
    return p;
  shift(p);
  s[p].n = i;
  s[p + 1].n -= i, s[p + 1].a += i;
  return p + 1;
}

void pack()
{
  n = 0;
  forn(i, sn)
    forn(j, s[i].n)
      b[n++] = s[i].a[j];
  swap(a, b);
}

void build()
{
  sn = 0;
  for (int i = 0; i < n; i += K)
    s[sn++] = {min(n - i, K), a + i};
}

int main()
{
  #define NAME "implicitkey"
  assert(freopen(NAME ".in", "r", stdin));
  assert(freopen(NAME ".out", "w", stdout));

  assert(scanf("%d%d", &n, &m) == 2 && n <= N && m <= N);
  forn(i, n)
    scanf("%d", &a[i]);

  build();
  while (m--)
  {
    char com[9];
    int i, p;
    scanf("%s%d", com, &i);
    if (com[0] == 'a')
    {
      scanf("%d", &a[n]);
      shift(p = split(i));
      s[p] = {1, a + n++};
    }
    else
    {
      split(i);
      erase(split(i - 1));
    }
    if (sn >= M)
      pack(), build();
  }
  pack();
  printf("%d\n", n);
  forn(i, n)
    printf("%d%c", a[i], " \n"[i == n - 1]);
  return 0;
}
