#include <bits/stdc++.h>
using namespace std;
int aa, bb;
pair<int, int> ans[101005];
int n, m;
struct segtree {
  int op[101005 << 2];
  int lma[101005 << 2], rma[101005 << 2], ma[101005 << 2];
  inline void up(int rt, int m) {
    int ll = m - (m >> 1), rr = m >> 1;
    if (lma[rt << 1] == ll)
      lma[rt] = lma[rt << 1] + lma[rt << 1 | 1];
    else
      lma[rt] = lma[rt << 1];
    if (rma[rt << 1 | 1] == rr)
      rma[rt] = rma[rt << 1] + rma[rt << 1 | 1];
    else
      rma[rt] = rma[rt << 1 | 1];
    ma[rt] = rma[rt << 1] + lma[rt << 1 | 1];
    ma[rt] = max(ma[rt], ma[rt << 1]);
    ma[rt] = max(ma[rt], ma[rt << 1 | 1]);
  }
  inline void fun(int rt, int opt, int m) {
    if (opt == -1) {
      lma[rt] = rma[rt] = ma[rt] = m;
      op[rt] = -1;
    }
    if (opt > 0) {
      lma[rt] = rma[rt] = ma[rt] = 0;
      op[rt] = opt;
    }
  }
  inline void down(int rt, int m) {
    if (op[rt] != 0) {
      fun(rt << 1, op[rt], m - (m >> 1));
      fun(rt << 1 | 1, op[rt], m >> 1);
      op[rt] = 0;
    }
  }
  void build(int l, int r, int rt) {
    op[rt] = 0;
    if (l == r) {
      lma[rt] = rma[rt] = ma[rt] = 1;
      return;
    }
    int mid = (l + r) >> 1;
    build(l, mid, rt << 1);
    build(mid + 1, r, rt << 1 | 1);
    up(rt, r - l + 1);
  }
  void update(int L, int R, int opt, int l, int r, int rt) {
    if (L <= l && r <= R) {
      fun(rt, opt, r - l + 1);
      return;
    }
    down(rt, r - l + 1);
    int mid = (l + r) >> 1;
    if (L <= mid) update(L, R, opt, l, mid, rt << 1);
    if (mid < R) update(L, R, opt, mid + 1, r, rt << 1 | 1);
    up(rt, r - l + 1);
  }
  int query(int num, int l, int r, int rt) {
    if (l == r) return l;
    down(rt, r - l + 1);
    int mid = (l + r) >> 1;
    int re = 0;
    if (ma[rt << 1] >= num)
      re = query(num, l, mid, rt << 1);
    else if (rma[rt << 1] + lma[rt << 1 | 1] >= num)
      re = mid - rma[rt << 1] + 1;
    else
      re = query(num, mid + 1, r, rt << 1 | 1);
    up(rt, r - l + 1);
    return re;
  }
  int getid(int pos, int l, int r, int rt) {
    if (op[rt]) return op[rt];
    int mid = (l + r) >> 1;
    if (pos <= mid)
      return getid(pos, l, mid, rt << 1);
    else
      return getid(pos, mid + 1, r, rt << 1 | 1);
  }
} st;
void doit() {
  int x, y;
  scanf("%d", &m);
  st.build(0, n + aa + bb - 1, 1);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    if (x == 1) {
      y = y + aa + bb;
      if (st.ma[1] < y) {
        printf("%d\n", -1);
        continue;
      }
      int re = st.query(y, 0, n + aa + bb - 1, 1);
      y = y - bb - aa;
      printf("%d\n", re);
      re += aa;
      st.update(re, re + y - 1, i, 0, n + aa + bb - 1, 1);
      ans[i].first = re;
      ans[i].second = re + y - 1;
    }
    if (x == 2) {
      st.update(ans[y].first, ans[y].second, -1, 0, n + aa + bb - 1, 1);
    }
  }
}
int main() {
  while (scanf("%d%d%d", &n, &aa, &bb) != EOF) doit();
  return 0;
}
