#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
const int maxint = -1u >> 1;
struct point {
  int lmax, rmax, maxlen, cov;
} p[maxn << 2];
void pushdown(int rt, int len) {
  if (p[rt].cov != -1) {
    p[rt << 1].maxlen = p[rt << 1].lmax = p[rt << 1].rmax =
        (p[rt].cov == 1) ? len - (len >> 1) : 0;
    p[rt << 1 | 1].maxlen = p[rt << 1 | 1].lmax = p[rt << 1 | 1].rmax =
        (p[rt].cov == 1) ? len >> 1 : 0;
    p[rt << 1].cov = p[rt << 1 | 1].cov = p[rt].cov;
    p[rt].cov = -1;
  }
}
void pushup(int rt, int len) {
  p[rt].lmax = p[rt << 1].lmax;
  p[rt].rmax = p[rt << 1 | 1].rmax;
  if (p[rt].lmax == len - (len >> 1)) p[rt].lmax += p[rt << 1 | 1].lmax;
  if (p[rt].rmax == (len >> 1)) p[rt].rmax += p[rt << 1].rmax;
  p[rt].maxlen = (p[rt << 1].maxlen > p[rt << 1 | 1].maxlen)
                     ? p[rt << 1].maxlen
                     : p[rt << 1 | 1].maxlen;
  p[rt].maxlen = (p[rt].maxlen > p[rt << 1].rmax + p[rt << 1 | 1].lmax)
                     ? p[rt].maxlen
                     : p[rt << 1].rmax + p[rt << 1 | 1].lmax;
}
void build(int l, int r, int rt) {
  p[rt].cov = -1;
  if (l == r) {
    p[rt].lmax = p[rt].rmax = p[rt].maxlen = 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 rt, int L, int R, int op) {
  int len = r - l + 1;
  if (L <= l && r <= R) {
    p[rt].lmax = p[rt].rmax = p[rt].maxlen = (op == 1) ? len : 0;
    p[rt].cov = op;
    return;
  }
  pushdown(rt, len);
  int m = (l + r) >> 1;
  if (L <= m) update(l, m, rt << 1, L, R, op);
  if (R > m) update(m + 1, r, rt << 1 | 1, L, R, op);
  pushup(rt, len);
}
int query(int l, int r, int rt, int w) {
  if (p[rt].lmax >= w) return l;
  pushdown(rt, r - l + 1);
  int m = (l + r) >> 1;
  if (p[rt << 1].maxlen >= w) return query(l, m, rt << 1, w);
  if (p[rt << 1].rmax + p[rt << 1 | 1].lmax >= w)
    return m - p[rt << 1].rmax + 1;
  return query(m + 1, r, rt << 1 | 1, w);
}
int main() {
  int n, b, f, op, w, m;
  int st[maxn], en[maxn];
  while (~scanf("%d%d%d", &n, &b, &f)) {
    n = n + b + f - 1;
    build(0, n, 1);
    scanf("%d", &m);
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &op, &w);
      if (op == 1) {
        if (p[1].maxlen >= b + w + f) {
          int idx = query(0, n, 1, w + b + f);
          printf("%d\n", idx);
          st[i] = idx + b;
          en[i] = idx + b + w - 1;
          update(0, n, 1, st[i], en[i], 0);
        } else
          printf("-1\n");
      } else {
        update(0, n, 1, st[w], en[w], 1);
      }
    }
  }
  return 0;
}
