#include <bits/stdc++.h>
using namespace std;
const int MaxA = 1e5 + 7;
struct Node {
  int v, l, r;
  void give(int x) { v = l = r = x; }
};
struct SegmentTree {
  Node c[MaxA << 2];
  int delay[MaxA << 2];
  void pushDown(int rt, int n) {
    if (delay[rt] != -1) {
      delay[rt << 1] = delay[rt << 1 | 1] = delay[rt];
      c[rt << 1].give((n - (n >> 1)) * (delay[rt] == 0));
      c[rt << 1 | 1].give((n >> 1) * (delay[rt] == 0));
      delay[rt] = -1;
    }
  }
  void pushUp(int rt, int n) {
    c[rt].v = max(max(c[rt << 1].v, c[rt << 1 | 1].v),
                  c[rt << 1].r + c[rt << 1 | 1].l);
    c[rt].l = (c[rt << 1].l == (n - (n >> 1)) ? c[rt << 1].l + c[rt << 1 | 1].l
                                              : c[rt << 1].l);
    c[rt].r = (c[rt << 1 | 1].r == (n >> 1) ? c[rt << 1].r + c[rt << 1 | 1].r
                                            : c[rt << 1 | 1].r);
  }
  void build(int l, int r, int rt) {
    if (l == r) {
      delay[rt] = -1;
      c[rt].give(1);
      return;
    }
    int m = l + r >> 1;
    build(l, m, rt << 1);
    build(m + 1, r, rt << 1 | 1);
    pushUp(rt, r - l + 1);
  }
  void update(int L, int R, int x, int l, int r, int rt) {
    if (L <= l && r <= R) {
      delay[rt] = x;
      c[rt].give((r - l + 1) * (x == 0));
      return;
    }
    pushDown(rt, r - l + 1);
    int m = l + r >> 1;
    if (L <= m) update(L, R, x, l, m, rt << 1);
    if (m < R) update(L, R, x, m + 1, r, rt << 1 | 1);
    pushUp(rt, r - l + 1);
  }
  int query(int x, int l, int r, int rt) {
    if (c[rt].l >= x) return l;
    pushDown(rt, r - l + 1);
    int m = l + r >> 1;
    if (c[rt << 1].v >= x) return query(x, l, m, rt << 1);
    if (c[rt << 1].r + c[rt << 1 | 1].l >= x) return m - c[rt << 1].r + 1;
    return query(x, m + 1, r, rt << 1 | 1);
  }
} st;
int L, b, f;
pair<int, int> lib[MaxA];
int main() {
  while (~scanf("%d%d%d", &L, &b, &f)) {
    int N = L + f;
    st.build(1, N, 1);
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      int op, x;
      scanf("%d%d", &op, &x);
      if (op == 1) {
        if ((st.c[1].l == L && st.c[1].l >= x) || st.c[1].l >= x + f) {
          st.update(1, x, 1, 1, N, 1);
          lib[i].first = 1;
          lib[i].second = x;
          printf("0\n");
        } else {
          int aa, bb = -1;
          if (st.c[1].v >= b + x + f) {
            aa = st.query(b + x + f, 1, N, 1) + b;
            bb = aa + x - 1;
          }
          if (bb == -1 || bb > L) {
            printf("-1\n");
            continue;
          }
          st.update(aa, bb, 1, 1, N, 1);
          lib[i].first = aa;
          lib[i].second = bb;
          printf("%d\n", aa - 1);
        }
      } else
        st.update(lib[x].first, lib[x].second, 0, 1, N, 1);
    }
  }
  return 0;
}
