#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 1000;
int len, b, f, n;
int lazy[maxn << 2], val[maxn << 2], pre[maxn << 2], suf[maxn << 2];
int a[150], c[150];
void pushup(int id, int l, int r) {
  int mid = l + r >> 1;
  val[id] = max(val[id << 1], val[id << 1 | 1]);
  pre[id] = pre[id << 1];
  suf[id] = suf[id << 1 | 1];
  if (pre[id << 1] == mid - l + 1) pre[id] += pre[id << 1 | 1];
  if (suf[id << 1 | 1] == r - mid) suf[id] += suf[id << 1];
  val[id] = max(val[id], suf[id << 1] + pre[id << 1 | 1]);
}
void pushdown(int id, int l, int r) {
  int mid = l + r >> 1;
  if (~lazy[id]) {
    lazy[id << 1] = lazy[id << 1 | 1] = lazy[id];
    val[id << 1] = pre[id << 1] = suf[id << 1] = lazy[id] ? mid - l + 1 : 0;
    val[id << 1 | 1] = pre[id << 1 | 1] = suf[id << 1 | 1] =
        lazy[id] ? r - mid : 0;
    lazy[id] = -1;
  }
}
void build(int id, int l, int r) {
  lazy[id] = -1;
  pre[id] = suf[id] = val[id] = r - l + 1;
  if (l == r) return;
  int mid = l + r >> 1;
  build(id << 1, l, mid);
  build(id << 1 | 1, mid + 1, r);
}
void update(int id, int l, int r, int L, int R, int op) {
  if (L <= l && R >= r) {
    pre[id] = suf[id] = val[id] = op ? r - l + 1 : 0;
    lazy[id] = op;
    return;
  }
  int mid = l + r >> 1;
  pushdown(id, l, r);
  if (L <= mid) update(id << 1, l, mid, L, R, op);
  if (R > mid) update(id << 1 | 1, mid + 1, r, L, R, op);
  pushup(id, l, r);
}
int query(int id, int l, int r, int lens) {
  int mid = l + r >> 1;
  if (l == r) return l;
  pushdown(id, l, r);
  if (lens <= val[id << 1])
    return query(id << 1, l, mid, lens);
  else if (lens <= pre[id << 1 | 1] + suf[id << 1])
    return mid - suf[id << 1] + 1;
  else
    return query(id << 1 | 1, mid + 1, r, lens);
}
int main() {
  scanf("%d%d%d%d", &len, &b, &f, &n);
  len += b + f;
  build(1, 1, len);
  int op, car;
  for (int j = 1; j <= n; j++) {
    scanf("%d%d", &op, &car);
    if (op == 1) {
      if (val[1] < car + b + f)
        puts("-1");
      else {
        int pos = query(1, 1, len, car + b + f);
        a[j] = pos + b;
        c[j] = pos + b + car - 1;
        printf("%d\n", pos - 1);
        update(1, 1, len, a[j], c[j], 0);
      }
    } else
      update(1, 1, len, a[car], c[car], 1);
  }
  return 0;
}
