#include <bits/stdc++.h>
using namespace std;
struct unit {
  int L;
  int R;
  int suml;
  int sumr;
  int sums;
  int flag;
  int len;
} node[820000];
void init() {
  for (int i = 0; i < 820000; i++) {
    node[i].suml = node[i].sumr = node[i].sums = 0;
    node[i].flag = -1;
  }
}
void pushup(int now) {
  node[now].suml = node[now * 2].suml;
  if (node[now * 2].suml == node[now * 2].len)
    node[now].suml += node[now * 2 + 1].suml;
  node[now].sumr = node[now * 2 + 1].sumr;
  if (node[now * 2 + 1].sumr == node[now * 2 + 1].len)
    node[now].sumr += node[now * 2].sumr;
  node[now].sums = max(max(node[now * 2].sums, node[now * 2 + 1].sums),
                       node[now * 2].sumr + node[now * 2 + 1].suml);
}
void pushdown(int now) {
  if (node[now].flag != -1) {
    node[now].suml = node[now].sumr = node[now].sums =
        node[now].len * node[now].flag;
    node[now * 2].flag = node[now * 2 + 1].flag = node[now].flag;
    node[now].flag = -1;
  }
}
void est(int L, int R, int now) {
  node[now].L = L;
  node[now].R = R;
  node[now].len = R - L;
  node[now].sums = node[now].suml = node[now].sumr = node[now].len;
  if (L == R - 1) return;
  int mid = L + (R - L) / 2;
  est(L, mid, now * 2);
  est(mid, R, now * 2 + 1);
  pushup(now);
}
int found(int len, int now) {
  pushdown(now);
  if (node[now].sums < len) return -1;
  if (node[now].suml >= len) {
    return node[now].L;
  } else {
    int temp = -1;
    temp = found(len, now * 2);
    if (temp != -1)
      return temp;
    else if (temp == -1) {
      if (node[now * 2].sumr + node[now * 2 + 1].suml >= len) {
        return node[now * 2].R - node[now * 2].sumr;
      }
    }
    temp = found(len, now * 2 + 1);
    if (temp != -1) return temp;
  }
  pushup(now);
  return -1;
}
void update(int L, int R, int now, int flag) {
  pushdown(now);
  if (node[now].L >= R || node[now].R <= L) return;
  if (node[now].L >= L && node[now].R <= R) {
    node[now].flag = flag;
    pushdown(now);
    return;
  }
  update(L, R, now * 2, flag);
  update(L, R, now * 2 + 1, flag);
  pushup(now);
}
pair<int, int> req[130];
int main() {
  int L, B, F;
  while (cin >> L >> B >> F) {
    init();
    est(0, L + F + B, 1);
    int m;
    cin >> m;
    for (int i = 1; i <= m; i++) {
      int op;
      scanf("%d", &op);
      if (op == 1) {
        int len;
        scanf("%d", &len);
        int st = found(len + B + F, 1);
        if (st == -1) {
          printf("-1\n");
          continue;
        }
        st += B;
        req[i] = make_pair(st, st + len);
        update(st, st + len, 1, 0);
        printf("%d\n", st - B);
      } else {
        int num;
        scanf("%d", &num);
        update(req[num].first, req[num].second, 1, 1);
      }
    }
  }
  return 0;
}
