#include <bits/stdc++.h>
using namespace std;
struct {
  int lmx, rmx, mx, flag;
} node[100210 << 2];
int lcar[100210], rcar[100210];
void pushup(int rt, int llen, int rlen) {
  node[rt].lmx = node[rt << 1].lmx;
  node[rt].rmx = node[rt << 1 | 1].rmx;
  node[rt].mx = max(node[rt << 1].mx, node[rt << 1 | 1].mx);
  node[rt].mx = max(node[rt].mx, node[rt << 1].rmx + node[rt << 1 | 1].lmx);
  if (node[rt].lmx == llen) node[rt].lmx += node[rt << 1 | 1].lmx;
  if (node[rt].rmx == rlen) node[rt].rmx += node[rt << 1].rmx;
}
void pushdown(int rt, int llen, int rlen) {
  if (node[rt].flag != -1) {
    node[rt << 1].lmx = node[rt << 1].rmx = node[rt << 1].mx =
        node[rt].flag * llen;
    node[rt << 1 | 1].lmx = node[rt << 1 | 1].rmx = node[rt << 1 | 1].mx =
        node[rt].flag * rlen;
    node[rt << 1 | 1].flag = node[rt << 1].flag = node[rt].flag;
    node[rt].flag = -1;
  }
}
void build(int rt, int l, int r) {
  int m = (l + r) >> 1;
  node[rt].flag = -1;
  if (r == l) {
    node[rt].lmx = node[rt].rmx = node[rt].mx = 1;
    return;
  }
  build(rt << 1, l, m);
  build(rt << 1 | 1, m + 1, r);
  pushup(rt, m - l + 1, r - m);
}
int query(int rt, int l, int r, int len) {
  int m = (l + r) >> 1;
  if (r - l + 1 == len) return l;
  pushdown(rt, m - l + 1, r - m);
  if (node[rt << 1].mx >= len)
    return query(rt << 1, l, m, len);
  else if (node[rt << 1].rmx + node[rt << 1 | 1].lmx >= len)
    return m - node[rt << 1].rmx + 1;
  else
    return query(rt << 1 | 1, m + 1, r, len);
}
void updata(int rt, int l, int r, int a, int b, int op) {
  int m = (l + r) >> 1;
  if (a <= l && r <= b) {
    node[rt].lmx = node[rt].rmx = node[rt].mx = op * (r - l + 1);
    node[rt].flag = op;
    return;
  }
  pushdown(rt, m - l + 1, r - m);
  if (b <= m)
    updata(rt << 1, l, m, a, b, op);
  else if (a > m)
    updata(rt << 1 | 1, m + 1, r, a, b, op);
  else {
    updata(rt << 1, l, m, a, m, op);
    updata(rt << 1 | 1, m + 1, r, m + 1, b, op);
  }
  pushup(rt, m - l + 1, r - m);
}
int main() {
  int n, b, f, m, op, len, pos, i;
  while (EOF != scanf("%d%d%d", &n, &b, &f)) {
    memset(node, 0, sizeof(node));
    memset(lcar, 0, sizeof(lcar));
    memset(rcar, 0, sizeof(rcar));
    build(1, -b, n + f - 1);
    scanf("%d", &m);
    for (i = 1; i <= m; i++) {
      scanf("%d%d", &op, &len);
      if (op == 1) {
        if (node[1].mx >= len + f + b) {
          pos = query(1, -b, n + f - 1, len + f + b);
          updata(1, -b, n + f - 1, pos + b, pos + b + len - 1, 0);
          lcar[i] = pos + b;
          rcar[i] = pos + b + len - 1;
          printf("%d\n", pos + b);
        } else
          printf("-1\n");
      } else
        updata(1, -b, n + f - 1, lcar[len], rcar[len], 1);
    }
  }
  return 0;
}
