#include <bits/stdc++.h>
#pragma GCC target("sse4.2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long MAXN = 1000 * 1000 + 7, MOD = 1000 * 1000 * 1000 + 7;
long long n, q, qu[MAXN], ans[MAXN];
vector<long long> vec;
map<long long, long long> pos;
struct node {
  long long sum[5] = {0, 0, 0, 0, 0}, cnt;
} seg[MAXN << 2];
node merge(node a, node b) {
  node res;
  res.cnt = a.cnt + b.cnt;
  for (long long i = 0; i < 5; i++) {
    cout << i << ": ";
    res.sum[i] = a.sum[i] + b.sum[((i - a.cnt) % 5 + 5) % 5];
    cout << "a.sum[" << i << "](" << a.sum[i] << ") + b.sum[" << i << " - "
         << a.cnt << "(" << b.sum[((i - a.cnt) % 5 + 5) % 5]
         << ") = " << res.sum[i] << endl;
  }
  return res;
}
void upd(long long val, long long x) {
  x += n;
  seg[x].cnt = (val > 0);
  seg[x].sum[0] += val;
  cout << "X: " << x << endl;
  for (long long i = x; i > 1; i >>= 1)
    cout << i * 2 << ":: ", seg[i >> 1] = merge(seg[i], seg[i ^ 1]);
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ;
  cin >> q;
  string s;
  for (long long i = 0; i < q; i++) {
    cin >> s;
    if (s == "sum") continue;
    long long x;
    cin >> x;
    vec.push_back(x);
    if (s == "del") x *= -1;
    qu[i] = x;
  }
  sort(vec.begin(), vec.end());
  vec.resize(distance(vec.begin(), unique(vec.begin(), vec.end())));
  n = vec.size();
  for (long long i = 0; i < n; i++) {
    cout << vec[i] << ' ';
    pos[vec[i]] = i;
  }
  cout << endl;
  for (long long i = 0; i < q; i++) {
    if (qu[i] == 0) {
      for (long long j = 0; j < 2 * n; j++) cout << seg[j].cnt << ' ';
      cout << endl;
      for (long long j = 0; j < 5; j++) cout << seg[1].sum[j] << ' ';
      cout << endl;
    } else {
      upd(qu[i], pos[abs(qu[i])]);
    }
  }
  return 0;
}
