#include <bits/stdc++.h>
int left[111111 << 2], right[111111 << 2], mx[111111 << 2], col[111111 << 2];
int len, back, front;
struct node {
  int op;
  int l, r;
} a[105];
inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a > b ? b : a; }
inline void setval(int rt, int val) { mx[rt] = left[rt] = right[rt] = val; }
void pushup(int rt, int m) {
  if (col[rt << 1] == col[rt << 1 | 1])
    col[rt] = col[rt << 1];
  else
    col[rt] = -1;
  mx[rt] = max(mx[rt << 1], mx[rt << 1 | 1]);
  mx[rt] = max(mx[rt], right[rt << 1] + left[rt << 1 | 1]);
  left[rt] = left[rt << 1];
  right[rt] = right[rt << 1 | 1];
  if (left[rt] == (m - (m >> 1))) left[rt] += left[rt << 1 | 1];
  if (right[rt] == (m >> 1)) right[rt] += right[rt << 1];
}
void pushdown(int rt, int m) {
  col[rt << 1] = col[rt << 1 | 1] = col[rt];
  if (col[rt] == 0) {
    mx[rt << 1] = left[rt << 1] = right[rt << 1] = (m - (m >> 1));
    mx[rt << 1 | 1] = left[rt << 1 | 1] = right[rt << 1 | 1] = (m >> 1);
  } else {
    mx[rt << 1] = left[rt << 1] = right[rt << 1] = 0;
    mx[rt << 1 | 1] = left[rt << 1 | 1] = right[rt << 1 | 1] = 0;
  }
}
void build(int l, int r, int rt) {
  if (l == r) {
    left[rt] = right[rt] = mx[rt] = 1;
    col[rt] = 0;
    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 val, int l, int r, int rt) {
  if (L <= l && r <= R) {
    col[rt] = val;
    if (val == 0)
      mx[rt] = left[rt] = right[rt] = r - l + 1;
    else
      mx[rt] = left[rt] = right[rt] = 0;
    return;
  }
  if (col[rt] != -1) pushdown(rt, r - l + 1);
  int m = (l + r) >> 1;
  if (L <= m) update(L, R, val, l, m, rt << 1);
  if (R > m) update(L, R, val, m + 1, r, rt << 1 | 1);
  pushup(rt, r - l + 1);
}
int query(int p, int l, int r, int rt) {
  if (mx[rt] < p) return -1;
  if (l == r) return l;
  if (col[rt] != -1) pushdown(rt, r - l + 1);
  int m = (l + r) >> 1;
  if (mx[rt << 1] >= p) return query(p, l, m, rt << 1);
  if (right[rt << 1] + left[rt << 1 | 1] >= p) return m - right[rt << 1] + 1;
  return query(p, m + 1, r, rt << 1 | 1);
}
int main() {
  int q, op, x, i, j, k;
  while (scanf("%d%d%d", &len, &front, &back) != EOF) {
    build(0, len - 1, 1);
    scanf("%d", &q);
    for (i = 1; i <= q; i++) {
      scanf("%d%d", &op, &x);
      a[i].op = op;
      if (op == 1) {
        if (x + back <= left[1]) {
          update(0, x - 1, i, 0, len - 1, 1);
          a[i].l = 0, a[i].r = x - 1;
          printf("%d\n", a[i].l);
          continue;
        }
        int t = query(x + back + front, 0, len - 1, 1);
        if (t == -1) {
          if (x + back <= left[1]) {
            update(0, x - 1, i, 0, len - 1, 1);
            a[i].l = 0, a[i].r = x - 1;
          } else if (x + front <= right[1]) {
            a[i].l = len - right[1] + front,
            a[i].r = len - right[1] + front + x - 1;
            update(len - right[1] + front, len - right[1] + front + x - 1, i, 0,
                   len - 1, 1);
          } else if (left[1] == len && x <= len) {
            update(0, x - 1, i, 0, len - 1, 1);
            a[i].l = 0, a[i].r = x - 1;
          } else {
            a[i].l = -1;
          }
        } else {
          if (t == 0) {
            update(0, x - 1, i, 0, len - 1, 1);
            a[i].l = 0, a[i].r = x - 1;
          } else {
            update(t + front, t + front + x - 1, i, 0, len - 1, 1);
            a[i].l = t + front, a[i].r = t + front + x - 1;
          }
        }
        printf("%d\n", a[i].l);
      } else if (op == 2) {
        update(a[x].l, a[x].r, 0, 0, len - 1, 1);
      }
    }
  }
  return 0;
}
