#include <bits/stdc++.h>
using namespace std;
void prepare() {}
const int maxl = 12201;
struct M {
  int x, l;
  M() {}
  M(int _x, int _l) : x(_x), l(_l) {}
  bool operator<(const M &p) const { return x < p.x || x == p.x && l < p.l; }
};
set<M> pl[maxl + 1];
int L, b, f;
int n;
M cars[105];
bool solve() {
  scanf("%d%d%d", &L, &b, &f);
  scanf("%d", &n);
  int LL = min(L + b + f, maxl);
  for (int i = LL; i >= 0; i--) pl[i].insert(M(-b, L + b + f));
  for (int cc = 0; cc < n; cc++) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int l;
      scanf("%d", &l);
      l += f + b;
      if (pl[l].empty())
        printf("-1\n");
      else {
        set<M>::iterator it = pl[l].begin();
        int xx = it->x;
        int ll = it->l;
        M mm = M(xx, ll);
        for (int i = min(LL, ll); i >= 0; i--) pl[i].erase(mm);
        int nx;
        int nl;
        nx = xx;
        nl = b;
        mm = M(nx, nl);
        for (int i = min(LL, nl); i >= 0; i--) pl[i].insert(mm);
        nx = xx + l - f;
        nl = ll - l + f;
        mm = M(nx, nl);
        for (int i = min(LL, nl); i >= 0; i--) pl[i].insert(mm);
        printf("%d\n", xx + b);
        cars[cc] = M(xx + b, l - f - b);
      }
    } else {
      int nc;
      scanf("%d", &nc);
      nc--;
      int xx = cars[nc].x;
      int ll = cars[nc].l;
      M mm = M(xx, ll);
      set<M>::iterator it = pl[0].lower_bound(M(xx, ll));
      if (it != pl[0].end() && it->x == xx + ll) {
        mm = M(xx, it->l + ll);
        M ud = M((it->x), (it->l));
        for (int i = min(LL, ud.l); i >= 0; i--) pl[i].erase(ud);
      }
      it = pl[0].lower_bound(M(xx, ll));
      if (it != pl[0].begin()) {
        --it;
        if (it->x + it->l == xx) {
          mm = M(it->x, it->l + mm.l);
          M ud = M((it->x), (it->l));
          for (int i = min(LL, ud.l); i >= 0; i--) pl[i].erase(ud);
        }
      }
      for (int i = min(LL, mm.l); i >= 0; i--) pl[i].insert(mm);
    }
  }
  return false;
}
int main() {
  prepare();
  while (solve())
    ;
  return 0;
}
