#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 7;
int L, B, F, N, car[maxN], stop[maxN], lazy[maxN << 2];
struct node {
  int ls, rs, ms;
  node(int a = 0, int b = 0, int c = 0) : ls(a), rs(b), ms(c) {}
} tree[maxN << 2];
void pushup(int rt, int l, int r) {
  int mid = (l + r) >> 1;
  tree[rt].ms = max(tree[rt << 1].rs + tree[rt << 1 | 1].ls,
                    max(tree[rt << 1].ms, tree[rt << 1 | 1].ms));
  tree[rt].ls = tree[rt << 1].ls;
  tree[rt].rs = tree[rt << 1 | 1].rs;
  if (tree[rt].ls == (mid - l + 1)) tree[rt].ls += tree[rt << 1 | 1].ls;
  if (tree[rt].rs == (r - mid)) tree[rt].rs += tree[rt << 1].rs;
  tree[rt].ms = max(tree[rt].ms, max(tree[rt].ls, tree[rt].rs));
}
void buildTree(int rt, int l, int r) {
  lazy[rt] = -1;
  if (l == r) {
    tree[rt] = node(1, 1, 1);
    return;
  }
  int mid = (l + r) >> 1;
  buildTree(rt << 1, l, mid);
  buildTree(rt << 1 | 1, mid + 1, r);
  pushup(rt, l, r);
}
void pushdown(int rt, int l, int r) {
  int mid = (l + r) >> 1;
  if (lazy[rt] != -1) {
    tree[rt << 1] = node(lazy[rt] * (mid - l + 1), lazy[rt] * (mid - l + 1),
                         lazy[rt] * (mid - l + 1));
    tree[rt << 1 | 1] =
        node(lazy[rt] * (r - mid), lazy[rt] * (r - mid), lazy[rt] * (r - mid));
    lazy[rt << 1] = lazy[rt << 1 | 1] = lazy[rt];
    lazy[rt] = -1;
  }
}
void update(int rt, int l, int r, int ql, int qr, int val) {
  if (ql <= l && qr >= r) {
    lazy[rt] = val;
    tree[rt] = node(val * (r - l + 1), val * (r - l + 1), val * (r - l + 1));
    return;
  }
  if (l == r) return;
  pushdown(rt, l, r);
  int mid = (l + r) >> 1;
  if (ql > mid)
    update(rt << 1 | 1, mid + 1, r, ql, qr, val);
  else if (qr <= mid)
    update(rt << 1, l, mid, ql, qr, val);
  else {
    update(rt << 1, l, mid, ql, qr, val);
    update(rt << 1 | 1, mid + 1, r, ql, qr, val);
  }
  pushup(rt, l, r);
}
int query(int rt, int l, int r, int num) {
  if (tree[rt].ls >= num) return l;
  pushdown(rt, l, r);
  int mid = (l + r) >> 1;
  if (tree[rt << 1].ms >= num)
    return query(rt << 1, l, mid, num);
  else if (tree[rt << 1].rs + tree[rt << 1 | 1].ls >= num)
    return mid - (tree[rt << 1].rs) + 1;
  else
    return query(rt << 1 | 1, mid + 1, r, num);
}
inline void init() { memset(stop, -1, sizeof(stop)); }
int main() {
  init();
  scanf("%d%d%d", &L, &B, &F);
  L += B + F;
  buildTree(1, 1, L);
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    int op, x;
    scanf("%d%d", &op, &x);
    if (op == 1) {
      car[i] = x;
      if (tree[1].ms < F + car[i] + B) {
        printf("-1\n");
        continue;
      }
      stop[i] = query(1, 1, L, F + car[i] + B);
      update(1, 1, L, stop[i] + B, stop[i] + B + car[i] - 1, 0);
      printf("%d\n", stop[i] - 1);
    } else {
      if (stop[x] == -1) continue;
      update(1, 1, L, stop[x] + B, stop[x] + car[x] + B - 1, 1);
      stop[i] = -1;
    }
  }
  return 0;
}
